fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class M{
  5. public: int database=0;
  6. M& operator=(M&& other){
  7. this->database=other.database;
  8. other.database=0;
  9. return *this;
  10.  
  11. }
  12. M(M &&other) {
  13. *this = std::move(other);
  14. }
  15. M (M& m)=default;
  16. M ()=default;
  17. ~M() { /* free db */ }
  18. };
  19.  
  20. class B{
  21. public: M shouldMove;
  22. //~B(){}
  23. };
  24.  
  25. int main() {
  26. B b;
  27. B b2=std::move(b);
  28. return 0;
  29. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
Standard output is empty