fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7. A()
  8. {
  9. cout << "A ctor" << endl;
  10. }
  11.  
  12. ~A()
  13. {
  14. cout << "A dtor" << endl;
  15. }
  16. };
  17.  
  18. class B
  19. {
  20. public:
  21. B()
  22. {
  23. cout << "B ctor" << endl;
  24. }
  25.  
  26. ~B()
  27. {
  28. cout << "B dtor" << endl;
  29. }
  30. };
  31.  
  32. class C
  33. {
  34. public:
  35. C()
  36. {
  37. cout << "C ctor" << endl;
  38. }
  39.  
  40. ~C()
  41. {
  42. cout << "C dtor" << endl;
  43. }
  44.  
  45. private:
  46. A a;
  47. B b;
  48. };
  49.  
  50. int main() {
  51. // your code goes here
  52. C c;
  53. return 0;
  54. }
Success #stdin #stdout 0.01s 5284KB
stdin
Standard input is empty
stdout
A ctor
B ctor
C ctor
C dtor
B dtor
A dtor