fork download
  1. #include <iostream>
  2.  
  3. class X {
  4. public:
  5. X() {
  6. std::cout << "X constructor called\n";
  7. }
  8.  
  9. X(const X &other) {
  10. std::cout << "X copy constructor called\n";
  11. }
  12.  
  13. ~X() {
  14. std::cout << "X destructor called\n";
  15. }
  16. };
  17.  
  18. X create_x() {
  19. X x;
  20. return x;
  21. }
  22.  
  23. int main() {
  24. auto x = create_x();
  25. return 0;
  26. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
X constructor called
X destructor called