CMPT 212
Object-Oriented Applications Design in C++
Fall 1997
Lecture 16
Wednesday, October 8, 1997
Classes with Pointers to Dynamic Memory (continued)
If the constructor allocates dynamic memory, the destructor should
almost always release it, unless there is a very good reason not to.
In that case, the comments in the program should describe exactly
what is going on and why.
If we didn't write our own copy constructor, an implicit copy
constructor would be used whenever we needed to copy a sentence.
The implicit copy constructor would do a shallow copy.
It would copy the pointers, but not what they point to.
Since we want a deep copy, we must write our own copy
constructor.