problem with parameters
In this case, i want to use a double parameter function, but i keep getting an error which says:
\error: too few arguments to function 'int add(int, int)' \
And here is the part of code that i`ve written and the compiler says it`s wrong:
int add(int x, int y)
return x + y;
by the way i use codeblocks compiler.
I think the problem will be when you are calling the function. How are you calling it? It should be in the form of add(int, int). Basically when you call a function the number and type of the arguments needs to match those of the function parameters.
Originally Posted by kasra5004
You are receiving this error because in your source code, somewhere you have defined 'add' to accept greater than two arguments when you are only supplying two.. Please make sure that you have defined add, that you have defined it to only hold those two integers. I'd be willing to bet you have defined it elsewhere to accept more than two args.
Please also make sure that wherever you call the function 'add' that you have supplied it with the proper arguments, such as: cout << "2 + 2 = " << add(2,2);
Sometimes when passing you accidentally hit the period (.) instead of a comma (,) so the compiler thinks you are only passing a double variable, hence the error.