fork(1) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class Chocolate
  6. {
  7. public:
  8. Chocolate() {
  9. cout << "Chocolate ctor" << endl;
  10. }
  11. ~Chocolate() {
  12. cout << "Chocolate dtor" << endl;
  13. }
  14. };
  15.  
  16. class ChocolateCake
  17. {
  18. public:
  19. ChocolateCake() {
  20. cout << "ChocolateCake ctor" << endl;
  21. }
  22. ~ChocolateCake() {
  23. cout << "ChocolateCake dtor" << endl;
  24. }
  25. private:
  26. Chocolate chocolate;
  27. };
  28.  
  29. class Candles
  30. {
  31. public:
  32. Candles() {
  33. cout << "Candles ctor" << endl;
  34. }
  35. ~Candles() {
  36. cout << "Candles dtor" << endl;
  37. }
  38. };
  39.  
  40. class BirthdayCake : public ChocolateCake
  41. {
  42. public:
  43. BirthdayCake() {
  44. cout << "BirthdayCake ctor" << endl;
  45. }
  46. ~BirthdayCake() {
  47. cout << "BirthdayCake dtor" << endl;
  48. }
  49. private:
  50. Candles candles;
  51. };
  52.  
  53. int main(int argc, char *argv[]) {
  54. BirthdayCake birthdayCake;
  55. return 0;
  56. }
Success #stdin #stdout 0s 4188KB
stdin
Standard input is empty
stdout
Chocolate ctor
ChocolateCake ctor
Candles ctor
BirthdayCake ctor
BirthdayCake dtor
Candles dtor
ChocolateCake dtor
Chocolate dtor