Lecture 11
Copy Assignment Operator
Student billy {...};
Student bobby {billy}; /// copy ctor
Student jane;
jane = billy; // copy assignment
jane.operator = (billy);
n1=n2; // n1.operator=(n2);
n1=n2=n3; // n2.operator = (n3);Node & Node::operator=(const Node &other) {
if (this==&other) return *this; // self assignment check
data = other.data;
delete next; // since we are updating on existing obj
next = other.next? new Node {*other.next}=nullptr;
return *this;
}Copy and Swap Idiom
Move Constructor
Move Assignment Operator
Last updated