fork download
  1. #include <iostream>
  2. using namespace std;
  3. class A
  4. {
  5. public:
  6. A()
  7. {
  8. cout << "constructor: " << this << endl;
  9. }
  10. A(const A & B)
  11. {
  12. cout << "copy constructor: " << this << endl;
  13. }
  14. A& operator=(const A & B)
  15. {
  16. cout << "copy asignment: " << this << endl;
  17. }
  18. ~A()
  19. {
  20. cout << "Destroyer: " << this << endl;
  21. }
  22. };
  23. A f()
  24. {
  25. A a;
  26. return a;
  27. }
  28. int main()
  29. {
  30. A b;
  31. b = f();
  32. A c=b;
  33. return 0;
  34. }
Success #stdin #stdout 0s 2728KB
stdin
Standard input is empty
stdout
constructor: 0xbf83ba1b
constructor: 0xbf83ba1a
copy asignment: 0xbf83ba1b
Destroyer: 0xbf83ba1a
copy constructor: 0xbf83ba19
Destroyer: 0xbf83ba19
Destroyer: 0xbf83ba1b