fork download
  1.  
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. class Room {
  6. public:
  7. Room() {
  8. cout << "Room created\n";
  9. }
  10.  
  11. ~Room() {
  12. cout << "Room destroyed\n";
  13. }
  14. };
  15.  
  16. class House {
  17. private:
  18. Room room;
  19.  
  20. public:
  21. House() {
  22. cout << "House created\n";
  23. }
  24.  
  25. ~House() {
  26. cout << "House destroyed\n";
  27. }
  28. };
  29.  
  30. int main() {
  31. House h;
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
Room created
House created
House destroyed
Room destroyed