Last active
August 29, 2015 14:00
-
-
Save onqtam/11352366 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
// OUTPUT IS: | |
// 500059 | |
// 500058 | |
// 2891316 | |
struct A { | |
void f() { | |
int a; // to take the stack address | |
std::cout << ((long long int)this - (long long int)&a) << std::endl; | |
} | |
}; | |
int main(int argc, char** argv) { | |
A a1; | |
A a2; | |
{ | |
//char array1[500000]; | |
a1.f(); | |
{ | |
char array2[500000]; | |
a2.f(); | |
} | |
} | |
A* a3 = new A; | |
a3->f(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment