Created
January 9, 2014 14:35
-
-
Save pasberth/8335035 to your computer and use it in GitHub Desktop.
進捗です
This file contains hidden or 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> | |
| typedef void (*f_t)(); | |
| class Base { | |
| public: | |
| virtual void f(); | |
| }; | |
| struct Derivied : public Base { | |
| public: | |
| void f(); | |
| }; | |
| void Base::f() | |
| { | |
| std::cout << "hello, I am base" << std::endl; | |
| } | |
| void Derivied::f() | |
| { | |
| std::cout << "hello, I am derived" << std::endl; | |
| } | |
| int main(int argc, char const *argv[]) | |
| { | |
| Derivied *x = new Derivied; | |
| void (***f)() = reinterpret_cast<f_t **>(x); | |
| (**f)(); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment