|
| Laeion (5) | |||
| s0ftware: Visual C++ 2008 Express inf0: Console Project c0de:
err0r: Compiling... Calculator.cpp calculator.cpp(20) : error C2146: syntax error : missing ';' before identifier 'cout' calculator.cpp(22) : error C2146: syntax error : missing ';' before identifier 'cout' calculator.cpp(24) : error C2146: syntax error : missing ';' before identifier 'cout' calculator.cpp(26) : error C2143: syntax error : missing ';' before '}' calculator.cpp(38) : error C2660: 'Process' : function does not take 1 arguments calculator.cpp(60) : error C2660: 'Process' : function does not take 1 arguments calculator.cpp(68) : error C2660: 'Process' : function does not take 1 arguments calculator.cpp(76) : error C2660: 'Process' : function does not take 1 arguments pr0blem: Not sure if I'm even doing this right. I tried using void Process(int a, int s, int m, int d) so I could type Process(a); in the int main(); sector, however, it isn't working out. | |||
| Umz (203) | |
| A function can only return a single value. Also your return statements need ; after them | |
| chrisname (2526) | |
| Can I ask why you've replaced all 'o's with '0's? Anywayway, it can only return one value and isn't meant to have parentheses. So, like this: return a; but you could do return a*5; You could try return a, b, c, d; but I doubt that would work. | |
| Disch (2127) | |||
| Umz is correct. To elaborate further, the 'return' instruction exits the function.
Returning multiple values with a comma (as per chrisname's suggestion) wouldn't work. Also the parenthesis aren't required, but don't really hurt anything. As for your last 4 errors -- it looks like you're attempting to call this function (which takes 4 arguments) but you're only giving it 1 argument when you call it. You need to supply all 4. From the looks of this function I'm guessing it's doing something much different than you think it is. | |||
| Laeion (5) | |||||
| Yeah, I tried to compress all 4 functions into one function, and tried calling on each return from the same function. Before this I had
and called the functions using
Is there any other way to compress all the void functions into one? and still being able to call on the functions? | |||||
| Disch (2127) | |||||
umm. sure:
=P Of course then you won't be able to call each small function individually, because you don't have any of those small functions anymore. If you want to be albe to call the small functions individually, you can keep them as they are, and make pMath call each of them. Like so:
| |||||
| jasmin m (15) | |||
| For that job, the best you can do is to use void function and call function by reference, something like this:
| |||
Last edited on | |||
This topic is archived - New replies not allowed.
