Skip to content

Instantly share code, notes, and snippets.

@mikhail-chystsiakou
Created January 19, 2017 14:57
Show Gist options
  • Save mikhail-chystsiakou/8d4502fabbcde84bd2c840ecaefee9c3 to your computer and use it in GitHub Desktop.
Save mikhail-chystsiakou/8d4502fabbcde84bd2c840ecaefee9c3 to your computer and use it in GitHub Desktop.
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