code_junkie

Diamond inheritance and pure virtual functions

Nov 13th, 2011
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. struct A {
  2. virtual void F() = 0;
  3. };
  4.  
  5. struct B : A { void F() { } };
  6. struct C : A { };
  7. struct D : B, C { };
  8.  
  9. D -> B::F
  10. D -> C -> A::F
  11.  
  12. F() F()
  13. A A
  14. | |
  15. F() B C
  16. /
  17. D
  18.  
  19. struct B : virtual A { void F() { } };
  20. struct C : virtual A { };
  21. struct D : B, C { };
  22.  
  23. F()
  24. A
  25. /
  26. F() B C
  27. /
  28. D
Add Comment
Please, Sign In to add comment