+ 2
cout<<(int)main; => 4199392 Why???
#include <iostream> using namespace std; int main() { cout<<(int)main; return 0; }
6 ответов
+ 4
Without paranthesis it writes 1, which cannot be memory adress, because the beginning of the RAM is reserved for jumping tables, stack etc. . With cast paranthesis I get 4199392 every time. If It were memory adress, it must be change depending of the content of RAM. You get this number if you run this code? If yes, than it is 100% that isn't an adress.
+ 2
I think the int is 4byte=32 bit, and the numbers stored in two complement, so the biggest number is 2^31-1 which is not 4199392.
+ 2
The memory adress of the function reference 'main', as you don't put parenthesis?
+ 2
My guess is:
The "main" name is only forbidden to use in global scope, in local scope you can declare a variable with name "main". I think it is a bug in the compiler. It must throw an error, because I try to wrote a value of a varible which is not initialized in local scope. The (int) is just a simple cast. I have no idea why I get back 4199392 instead of 1 if I use it...
0
the maximum numeric value?
0
I doubt it thou