fork download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. class A
  6. {
  7. int myint;
  8. public:
  9. A():myint(0)
  10. {
  11. cout << this << " A():myint(0) myint == "<<myint<<endl;
  12. }
  13. A(int i):myint(i)
  14. {
  15. cout << this << " A(int i):myint(i) myint == "<<myint<<endl;
  16. }
  17. ~A()
  18. {
  19. cout << this << " delete A()"<<endl;
  20. }
  21.  
  22. A& operator=(const A &other) {
  23. cout << "Assign " << &other << " to " << this << endl;
  24. myint = other.myint;
  25. }
  26. };
  27.  
  28.  
  29. int main()
  30. {
  31. A a;
  32. a = 2;
  33.  
  34. return 0;
  35. }
  36.  
Success #stdin #stdout 0s 4464KB
stdin
Standard input is empty
stdout
0x7ffc42934560 A():myint(0) myint == 0
0x7ffc42934570 A(int i):myint(i) myint == 2
Assign 0x7ffc42934570 to 0x7ffc42934560
0x7ffc42934570 delete A()
0x7ffc42934560 delete A()