Move Assignment Operator
An example of this as seen in CS247.
Definition
Node& Node::operator=(Node&& other) {
std::swap(data, other.data);
std::swap(next, other.next);
return *this;
}
Usage
Node n{"1", new Node{"2", new Node{"3", nullptr}}};
n = getAlphabet(); // Move assignment operator
// Another way
Node b;
n = std::move(b);
Move Constructor vs. Move Assignment Operator
A a("Hello");
A aa("World");
A b = std::move(a); // Move constructor is called to transfer resources from 'a' to 'b'
a = std::move(aa); // Move assignment operator is called to transfer resources from 'aa' to 'a'