fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct test {
  5. test() { cout << "constructor" << endl; }
  6. test(const test&) { cout << "copy constructor" << endl; }
  7. test(test&&) { cout << "move constructor" << endl; }
  8. ~test() { cout << "destructor" << endl; }
  9. };
  10.  
  11. struct nested {
  12. test t;
  13. // nested() {}
  14. };
  15.  
  16. auto main() -> int {
  17. // prints "constructor", "copy constructor" and "destructor"
  18. auto n = nested{};
  19. cout << endl;
  20.  
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
constructor

destructor