So I'm trying to use a function display, and assign 3 numbers to its 3 parameters. Then in my main function, I'm trying to display each argument. I can't seem to define the arguments right with a few other errors. Here is my code:
#include <iostream>
usingnamespace std;
int display(int, int,int);
int main()
{
cout << "Here are the values: "
<< display(arg1) << " " << display(arg2)<< " "
<< display(arg3)<< endl;
}
int display(int arg1, int arg2, int arg3){
int arg1=1;
int arg2=2;
int arg3=3;
}
}
Your forward declaration of display (line 5) doesn't match your definition of display (line 14). Make sure those match up.
Line 11/12: You're calling display 3 times with 1 argument each after you've defined display to take in 3 arguments at a time.
Inside display, you're creating new local variables with the same names as your parameters, assigning them a value, then doing nothing with them. They will automatically be deleted after you finish running the function.
Display has a return type of integer, but you never return anything, so that will cause a problem as well.
Your forward declaration of display (line 5) doesn't match your definition of display (line 14). Make sure those match up.
Actually they do match. The parameter names are not actually needed, although adding meaningful parameter names help document the function.
I can't seem to define the arguments right with a few other errors.
If you receive compiler errors post the complete error listing exactly as it appears in your development environment. These messages have important information embedded within them to aid in locating and fixing the problems.
I can see no problems with the declaration in line 5.
Function's parameters are LOCAL to the function. Any changes you make to them inside the function will be lost when the function completes executing.
For a function to have any effect on the rest of your program, you have to make the function return a value. It can return only one value. Use the return keyword to return a value.