previous |
start |
next
Automatic Memory Management
- The assignment operator, copy constructor, and
destructor are collectively called the "big three."
- You must implement all three for any class that
manages heap memory.
- Each function has the following logic.
- Destructor:
Free all dynamic memory that the object manages.
- Copy Constructor:
Initialize the object as a copy of the explicit parameter
object.
- Assignment Operator:
Check whether this == &b. If so do
nothing.
Free the dynamic memory of the object that is no longer
needed.
Set the object as a copy of the explicit parameter object.
Return *this.
previous |
start |
next