Guest User

Untitled

a guest
Sep 13th, 2015
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6.     void foo() { cout << "A::foo()\n"; }
  7. };
  8.  
  9. struct B : virtual A
  10. {
  11.     virtual void foo() { cout << "B::foo()\n"; }
  12. };
  13.  
  14. struct C : B, virtual A
  15. {
  16.     void foo() { cout << "C::foo()\n"; }
  17. };
  18.  
  19. int main (int argc, char *argv[])
  20. {
  21.     C().foo();
  22.     A *a = new C; a->foo();
  23.     static_cast<A*>(new C)->foo();
  24.     return 0;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment