Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- class C{
- public:
- int x;
- void f(){
- printf("\nHello world!\n");
- printf("this == %p\n", this);
- printf("x == %d\n", x);
- }
- };
- int main(){
- C c;
- c.f();
- C *p = reinterpret_cast<C*>(0xfe58648); //nonsense address
- p->f();
- }
- //Output:
- Hello world!
- this == 0x7fff656e3a40
- x == 0
- Hello world!
- this == 0xfe58648
- Segmentation fault: 11
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement