fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class A
  5. {
  6. public:
  7. A() { cout << "A constructor" << endl; }
  8. A(const A& a) { cout << "A copy constructor" << endl; }
  9. ~A() { cout << "A destructor" << endl; }
  10. };
  11.  
  12. A ACreator()
  13. {
  14. cout << "Creating a on stack" << endl;
  15. A res = A();
  16. cout << "Returning a" << endl;
  17. return res;
  18. }
  19.  
  20. void Test()
  21. {
  22. cout << "Calling ACreator() to get some A" << endl;
  23. A a = ACreator();
  24. cout << "Got some a" << endl;
  25. }
  26.  
  27. int main() {
  28. cout << "Calling Test()" << endl;
  29. Test();
  30. cout << "Test ended. Returning 0" << endl;
  31. return 0;
  32. }
Success #stdin #stdout 0s 3344KB
stdin
Standard input is empty
stdout
Calling Test()
Calling ACreator() to get some A
Creating a on stack
A constructor
Returning a
Got some a
A destructor
Test ended. Returning 0