Starting from the top of the program, the first thing the compiler sees is:
The next thing the compiler sees is:
This is a second variable named what but this one is local to main(). The int what outside of main is completely blocked by this local one.
Then the compiler sees:
- cout << what(9,3,17) << endl;
-
so you get an error trying to use variable as a function. There is a what function, but the compiler hasn't seen it yet.
YOu need a function prototype:
- int what(int x, int y, int z);
-
-
int main()
-
{
-
what(9,3,17); // this is now OK
-
}
The function prototype is the first line of the function definition ended by a semicolon. This tells the compiler there is a function what with 3 int arguments.
Lastly, never name your variables and your functions using the same name.