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