fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A {
  5. int x;
  6. public:
  7. A() { x = 1; cout << "A"; }
  8. };
  9. class B : virtual public A {
  10. int y;
  11. public:
  12. B() { y = 2; cout << "B"; }
  13. };
  14. class C : virtual public B, virtual public A {
  15. int z;
  16. public:
  17. C() { z = 3; cout <<"C"; }
  18. };
  19. class D : public A, public B, public C {
  20. int t;
  21. public:
  22. D() { t = 4; cout << "D"; }
  23. };
  24. int main()
  25. {
  26. D d;
  27. return 0;
  28. }
Success #stdin #stdout 0s 2896KB
stdin
Standard input is empty
stdout
ABABCD