Advertisement
Waliul

The diamond problem solution

Jan 16th, 2022
951
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.41 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7.     A()
  8.     {
  9.         cout<<"A constructor called\n\n";
  10.     }
  11. };
  12.  
  13. class B: virtual public A
  14. {
  15. public:
  16.     B()
  17.     {
  18.         cout<<"B constructor called\n\n";
  19.     }
  20. };
  21.  
  22. class C: virtual public A
  23. {
  24. public:
  25.     C()
  26.     {
  27.         cout<<"C constructor called\n\n";
  28.     }
  29. };
  30.  
  31. class E: virtual public A
  32. {
  33. public:
  34.     E()
  35.     {
  36.         cout<<"E constructor called\n\n";
  37.     }
  38. };
  39.  
  40. class F: virtual public A
  41. {
  42. public:
  43.     F()
  44.     {
  45.         cout<<"F constructor called\n\n";
  46.     }
  47. };
  48.  
  49. class G: public E, public F
  50. {
  51. public:
  52.     G()
  53.     {
  54.         cout<<"G constructor called\n\n";
  55.     }
  56. };
  57.  
  58. class H
  59. {
  60. public:
  61.     H()
  62.     {
  63.         cout<<"H constructor called\n\n";
  64.     }
  65. };
  66.  
  67. class I: virtual public H, virtual public C
  68. {
  69. public:
  70.     I()
  71.     {
  72.         cout<<"I constructor called\n\n";
  73.     }
  74. };
  75.  
  76. class J: virtual public H
  77. {
  78. public:
  79.     J()
  80.     {
  81.         cout<<"J constructor called\n\n";
  82.     }
  83. };
  84.  
  85. class K: virtual public I, public J
  86. {
  87. public:
  88.     K()
  89.     {
  90.         cout<<"K constructor called\n\n";
  91.     }
  92. };
  93.  
  94. class L: virtual public I
  95. {
  96. public:
  97.     L()
  98.     {
  99.         cout<<"L constructor called\n\n";
  100.     }
  101. };
  102.  
  103. class D: public B, virtual public C, public G, public L, public K
  104. {
  105. public:
  106.     D()
  107.     {
  108.         cout<<"D constructor called\n\n";
  109.     }
  110. };
  111.  
  112. int main()
  113. {
  114.     D d1;
  115. }
  116.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement