fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class X{
  5. int a;
  6. public:
  7. X(int a) : a(a){std::cout<<"in constructor";}
  8. // X(const X& x) : a(x.a){std::cout<<"in copy constructor";}
  9. X(const X& x) = delete;
  10. X& operator=(const X& x){
  11. std::cout<<"in assignment";
  12. a = x.a;
  13. return *this;
  14. }
  15. };
  16.  
  17.  
  18. int main(int argc, char *argv[])
  19. {
  20. X x1(3);
  21. X x2(5);
  22. x1 = x2;
  23. return 0;
  24. }
  25.  
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
in constructorin constructorin assignment