fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class Base {
  5. public:
  6. Base(){
  7. cout<<"create Base "<<this<<endl;
  8. }
  9. Base(const Base& a){
  10. cout<<"create copy Base "<<this<<" "<<&a<<endl;
  11. }
  12. Base(Base&& a)
  13. {
  14. cout<<"create move Base "<<this<<" "<<&a<<endl;
  15. }
  16. ~Base() {
  17. cout<<"deleting Base "<<this<<endl;
  18. }
  19.  
  20. Base & operator = (const Base &a)
  21. {
  22. cout<<"operator "<<this<<" "<<&a<<endl;
  23. return *this;
  24. }
  25. Base & operator = (const Base &&a)
  26. {
  27. cout<<"operator move "<<this<<" "<<&a<<endl;
  28. return *this;
  29. }
  30.  
  31.  
  32. };
  33.  
  34. Base func (Base x)
  35. {
  36. cout<<"*********************"<<endl;
  37.  
  38. return Base(x);
  39. }
  40.  
  41. int main()
  42. {
  43.  
  44. Base a;
  45.  
  46.  
  47. Base b;
  48.  
  49. cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
  50.  
  51. b = func (a);
  52.  
  53. cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
  54.  
  55. return 0;
  56. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
create Base 0xbfbbf59c
create Base 0xbfbbf59d
!!!!!!!!!!!!!!!!!!!!!!!!!!
create copy Base 0xbfbbf59e 0xbfbbf59c
*********************
create copy Base 0xbfbbf59f 0xbfbbf59e
operator move 0xbfbbf59d 0xbfbbf59f
deleting Base 0xbfbbf59f
deleting Base 0xbfbbf59e
!!!!!!!!!!!!!!!!!!!!!!!!!!
deleting Base 0xbfbbf59d
deleting Base 0xbfbbf59c