what's wrong with this?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

using namespace std;

void z()
{
cout << "z";
}

int main()
{
cout << "the name of function: " << z;
cout << endl;
return 0;
}


the output is "1" instead of "the name of function: z".. hmm??
call the function, do this instead:

cout << "the name of function: " << z();
You're missing the brackets:

cout << "the name of function: " << z();

just printing z means you're printing the function's address in memory.
omg what a careless mistake! thx guys.. haha, long time didn't touch c++
Topic archived. No new replies allowed.