| ethrtyiS (6) | |||
|
Hey I'm new to C++ and I'm having an issue with the current program I am writing. I am getting only getting one error. Can someone tell me what I am doing wrong. I have been trying to fix it all night. I am not allowed to use global variables which has made it much more difficult on me. I know I need to declare it the three somewhere but even when I declare the 3 arguments in the spacer or monthNums functions, I am still getting the same error. Thanks in advance. Here is the error: error C2660: 'monthNums' : function does not take 3 arguments - 212.Here is my full code:
| |||
|
Last edited on
|
|||
| Peter87 (3672) | |
| You have defined monthNums to take 5 arguments but you only pass it 3. | |
|
|
|
| ethrtyiS (6) | |||
|
Peter, I have tried that as well but it throws even more errors that I don't even know what they mean. Here is what I'm doing:
And I get these errors now: 1. IntelliSense: too few arguments in function call - 2122. error LNK2019: unresolved external symbol "void __cdecl wrapper(int,int)" (?wrapper@@YAXHH@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)3. error LNK2019: unresolved external symbol "void __cdecl spacer(int,int &,int,int &)" (?spacer@@YAXHAAHH0@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)4. error LNK2019: unresolved external symbol "void __cdecl printCal(int,int)" (?printCal@@YAXHH@Z) referenced in function _main5. error LNK2019: unresolved external symbol "void __cdecl monthNums(int,int &,int &)" (?monthNums@@YAXHAAH0@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)6. error LNK2019: unresolved external symbol "void __cdecl monthNames(int)" (?monthNames@@YAXH@Z) referenced in function "void __cdecl printCal(int,int,int,int,int,int,int)" (?printCal@@YAXHHHHHHH@Z)7. error LNK1120: 5 unresolved externals C:\Users\ethrtyiS\documents\visual studio 2010\Projects\calendar\Debug\calendar.exe 1
| |||
|
|
|||
| slicedpan (155) | |||||
These should not be inside a function. Also your function prototype for printCal does not match the actual definition.
In your main you call it with two arguments, but the actual function takes at least 5. | |||||
|
Last edited on
|
|||||
| ethrtyiS (6) | |
| Slicedpan, how do I go about not having them inside my function? Should I declare them like that but after namespace? Also, for the main should I include the other ints? | |
|
|
|
| slicedpan (155) | |||
They can come either before or after the using statement (if they contain arguments that are in that namespace then they should be after, but this is not the case).
Probably, however I should be honest and say this code probably needs a rewrite, I really can't make sense of some of it, and even if you get it to compile I don't think it's going to do what you think it's going to do. I would go back to the drawing board tbh. | |||
|
|
|||
| ethrtyiS (6) | |
| Hm, I've already rewrote it twice. I had this thing working just fine when I was using global variables. Now it just seems to have gone haywire. I just don't know what I am doing wrong. Can you give me an idea of how I should go about rewriting it if I do end up going that route again? | |
|
|
|
| slicedpan (155) | |
| If you had it fine using global variables, then you should have stuck with that, for a small program like this, global variables are fine. | |
|
|
|
| ethrtyiS (6) | |
| Right but my professor doesn't want us using global variables, which like I said earlier, made it very difficult. | |
|
|
|
| slicedpan (155) | |
| That.... sucks. Well I would start from the version using global variables, since you know that works. First I would delete the global variables, and declare them instead inside the main function. Then try and work out which function needs which variables, and pass them down from one function to the next. | |
|
|
|