fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct MyClass
  5. {
  6. MyClass()
  7. {
  8. cout<<"Constructing!"<<endl;
  9. }
  10. ~MyClass()
  11. {
  12. cout<<"Destroying!"<<endl;
  13. }
  14. };
  15.  
  16. MyClass DoSomething()
  17. {
  18. return MyClass();
  19. }
  20.  
  21. int main() {
  22. cout<<"Starting program"<<endl;
  23. const MyClass& a = DoSomething();
  24. cout<<"End of program."<<endl;
  25. return 0;
  26. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Starting program
Constructing!
End of program.
Destroying!