class base
{
public:
base(const base&) = delete;
base()
{
cout << "construct" << endl;
}
~base()
{
cout << "destruct" << endl;
}
int a;
int b;
/* The difference explanation I desired is here */
void operator=(base&& other)
// base& operator=(base&& other) // this needs to collaborate with "return *this"
{
this->a = other.a;
this->b = other.b;
// return *this;
}
/* Not here */
base& operator=(base& other) = delete;
};
What is the difference between the two versions of operator=(T&&)
? They seem both work to me. However, as class member function, the website recommand base& operator=(T&&)
version.