Created
May 20, 2016 21:21
-
-
Save false-git/6755af7c91ab73e76102c370a3000fbc 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> | |
class A { | |
public: | |
void method() { | |
std::cout << "A::method" << std::endl; | |
} | |
virtual void vmethod() { | |
std::cout << "A::vmethod" << std::endl; | |
} | |
}; | |
class B { | |
public: | |
void method() { | |
std::cout << "B::method" << std::endl; | |
} | |
virtual void vmethod() { | |
std::cout << "B::vmethod" << std::endl; | |
} | |
}; | |
class C {}; | |
class D: public A, B, C {}; | |
int main() { | |
D d; | |
std::cout << (A*)&d << std::endl; | |
std::cout << (B*)&d << std::endl; | |
std::cout << (C*)&d << std::endl; | |
((A*)&d)->A::method(); | |
((B*)&d)->B::method(); | |
((A*)&d)->method(); | |
((B*)&d)->method(); | |
((A*)&d)->A::vmethod(); | |
((B*)&d)->B::vmethod(); | |
((A*)&d)->vmethod(); | |
((B*)&d)->vmethod(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment