- Copy constructor: remember to call base(rhs) in the initialize list.
- Assignment Operator: remember to call base::operator=(rhs) inside if (this =! &rhs)
- compiler will use the default constructor and default assignment operator. it turns out they do not initialize the base part properly and do not assign new value.
- derive class cannot access the private stuff in the base class, therefore we need public copy constructor and public (copy) assignment operator to deal with the base class subobject.
Effective C++, copy all parts of an object.
No comments:
Post a Comment