 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
| • |
Whenever
there is dynamic memory allocated on an
|
|
|
object-by-object
basis in a class, we should overload the
|
|
|
assignment
operator for the same reasons that require the
|
|
|
copy
constructor
|
|
|
| • |
The
assignment operator must be overloaded as a member,
|
|
and
it doesn’t modify the second operand (so if it is an
|
|
|
object
of a class -- it should be a const ref.)
|
|
|
| • |
The
assignment operator can be chained, so it should
|
|
|
return
an lvalued object, by reference
|
|
|
| • |
It
modifies the current object, so it cannot be a const
|
|
|
member
function
|
|