fork download
  1. #include <iostream>
  2.  
  3. struct MyClass
  4. {
  5. MyClass() //default ctor
  6. {
  7. std::cout << "Constructed" << std::endl;
  8. }
  9. MyClass(MyClass const&from) //copy ctor
  10. {
  11. std::cout << "Copied" << std::endl;
  12. }
  13. ~MyClass() //dtor
  14. {
  15. std::cout << "Destructed" << std::endl;
  16. }
  17. };
  18.  
  19. void f(MyClass) //pass by value
  20. {
  21. std::cout << "f" << std::endl;
  22. }
  23.  
  24. int main()
  25. {
  26. MyClass mc;
  27. f(mc);
  28. std::cout << "End of main" << std::endl;
  29. }
  30.  
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
Constructed
Copied
f
Destructed
End of main
Destructed