fork download
  1. #include <iostream>
  2. #include <utility>
  3. using namespace std;
  4.  
  5. class A
  6. {
  7. int data;
  8. public:
  9. A(): data{0}
  10. {
  11.  
  12. }
  13.  
  14. A(const A& other)
  15. {
  16. print(other);
  17. }
  18.  
  19.  
  20. A(A&& other)
  21. {
  22. print(other);
  23. }
  24.  
  25. void print(const A& other) const
  26. {
  27. cout << "In print 1" << endl;
  28. }
  29.  
  30. void print(const A&& other) const
  31. {
  32. cout << "In print 2" << endl;
  33. }
  34.  
  35. };
  36.  
  37.  
  38. int main() {
  39. A a0;
  40. A a1(a0);
  41. A a2(std::move(a1));
  42.  
  43. return 0;
  44. }
Success #stdin #stdout 0s 4488KB
stdin
Standard input is empty
stdout
In print 1
In print 1