fork(1) download
  1. #include <iostream>
  2.  
  3. class Mother
  4. {
  5. public:
  6. virtual void foo1() { }
  7. int a;
  8. };
  9.  
  10. class Father
  11. {
  12. public:
  13. virtual void foo2() { }
  14. int b;
  15. };
  16.  
  17. class Child : public Mother, public Father
  18. {
  19. public:
  20. int c;
  21. };
  22.  
  23. int main()
  24. {
  25. Child c;
  26. Mother* m = &c;
  27. Father* f = &c;
  28.  
  29. if ((void*)&c == (void*)m)
  30. {
  31. std::cout << "I like Mother." << std::endl;
  32. }
  33.  
  34. if ((void*)&c == (void*)f)
  35. {
  36. std::cout << "I like Father." << std::endl;
  37. }
  38.  
  39. return 0;
  40. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
I like Mother.