Created
January 19, 2017 14:57
-
-
Save mikhail-chystsiakou/8d4502fabbcde84bd2c840ecaefee9c3 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
class A { | |
public: | |
int a; | |
}; | |
class AA : public A { | |
public: | |
int b; | |
}; | |
int main() { | |
A* a = new A(); | |
a->a = 5; | |
AA* aa = reinterpret_cast<AA*>(a); | |
cout << aa->a << endl; | |
cout << aa->b << endl; | |
aa->a = 6; | |
aa->b = 7; | |
cout << aa->a << endl; | |
cout << aa->b << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment