Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- class Base {
- public:
- virtual void Test() {
- std::cout << "Base";
- }
- };
- class Child : public Base{
- public:
- void Test() {
- std::cout << "Child";
- }
- };
- void polyTest(Base x) {
- int ptr = *(int*)&x;
- typedef void(*func)(void*);
- func testFunc = (func)(*(int*)(ptr));
- testFunc(&x);
- }
- int main(int argc, char const *argv[])
- {
- Child foo;
- polyTest(foo);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement