fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7. A(){cout << "I am in the A constructor " << endl;}
  8. ~A(){cout << "I am In the A destructor "<< endl;}
  9. };
  10.  
  11. class AX
  12. {
  13. public:
  14. AX(){cout<<"I am in the AX constructor" << endl;}
  15. ~AX(){cout <<"I am in the AX destructor" << endl;}
  16. AX(int x){cout<<"I am in AX param constructor"<< endl;}
  17.  
  18. };
  19. class AXX
  20. {
  21. public:
  22. AXX(){cout << "I amin the AXX constructor"<<endl;}
  23. ~AXX(){cout << "I am in the AXX destructor "<< endl;}
  24. AXX(int x)
  25. {
  26. cout <<"I am in the AXX param constructor" << endl;
  27. }
  28. };
  29. class B : public A
  30. {
  31. AX ax;
  32. AXX axx;
  33. public:
  34. B():axx(6){cout <<"I amin B constructor"<< endl;}
  35. ~B(){cout << "I am in the B destrcuctor "<< endl;}
  36. };
  37. class C : public B
  38. {
  39. AXX axx;
  40. AX ax;
  41. public :
  42. C() : ax(5),axx(6) {cout << "I am in c constructor" << endl;}
  43. ~C(){cout << "I am in the c destructor" << endl;}
  44. };
  45. int main() {
  46. // your code goes here
  47. C c1;
  48. return 0;
  49. }
Success #stdin #stdout 0s 3416KB
stdin
Standard input is empty
stdout
I am in the A constructor 
I am in the AX constructor
I am in the AXX param constructor
I amin B constructor
I am in the AXX param constructor
I am in AX param constructor
I am in c constructor
I am in the c destructor
I am in the AX destructor
I am in the AXX destructor 
I am in  the B destrcuctor 
I am in the AXX destructor 
I am in the AX destructor
I am In the A destructor