C++ why do I get hex number

Ok I want to know why most of the time if I program something. In my program,
The sometime be a hexadecimal number be on top of my program.

http://img225.imageshack.us/img225/1596/programming.png
Last edited on
Hex numbers are preceded by 0x. Rest of your question, I don't understand.

EDIT:
Generally*. I think VS does not do this for some reason. May be a hex, or may be garbage. I really dont know what

cout << functionID

does. Seems weird, and I feel like not what you're trying to do.
Last edited on
Are you talking about the 01211...? It's the address of the function "addition".
Did you look at the screenshot you will understand a little bit.
you will see "01211028" when the should be 7 output.
after all the function argument was addition(3,4);
I did, hence the edit. You're not calling the function there. You call after your cout, so I'm not sure what your logic there was.

cout << functionID(arg, arg)
Yes! BlackSheep, but why did it appear and my outcome of "a and b" did not appear.

@Regisdent have you every try
cout<<FunctionID(arg,arg);
in C++ before, if it work for you. It don't work for me
Last edited on
I just told you. Look at your code. Programs execute from top to bottom. Do you call your function in your output statement? No, you call it afterwards. I'm surprised this even runs (unless addition is a void function? Even then it doesn't make sense).
I just ran this little piece of code:
1
2
3
4
5
6
7
8
9
10
11
int func()
{return 0;}

int main()
{
	int(*pFunc)() = func;
	std::cout<<pFunc<<std::endl;
    std::cout<<func;
	cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
    return 0;
}

And as I (unexpectedly) expected, both pFunc and <<func gave the same value (Pointer to func).
Was compiled using MVC++10, and I too am rather confused. Do functions automagically decay to their address pointer when used as a variable?
PSEUDO-EDIT: Looked it up, and apparently function names themselves do decay to the address automatically. Didn't know this.
Last edited on
Topic archived. No new replies allowed.