When the assignment hp = hp2;
is executed, the copy-assignment operator is used. First, data members of rhs
(i.e. hp2
) are copyed. Then, data members of rhs
(i.e. hp
) are deleted. Finally, the copyed data members of rhs
are assigned to those of lhs
.
When the assignment hp = std::move(hp2);
is executed, the move-assignment operator is used. First, std::move()
return the rvalue reference to hp2
. Second, the data members of the rhs
(i.e. rvalue reference to hp2
) are moved to those of lhs
(i.e. hp1
). Finally, the data members of rhs
are assigned to valid values for destruction.