fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A{
  5. void foo() { cout <<"A::foo" <<endl; }
  6. };
  7.  
  8. struct B : A{
  9. void foo() { cout <<"B::foo" <<endl; }
  10. };
  11.  
  12. struct C : A{
  13. void foo() { cout <<"C::foo" <<endl; }
  14. };
  15.  
  16. struct D : B, C {
  17. void foo() { cout <<"D::foo" <<endl; }
  18. };
  19.  
  20. int main() {
  21. D d;
  22. d.foo();
  23. return 0;
  24. }
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
D::foo