If a base class uses dynamic memory allocation, and redefines a copy constructor and assignment operator

    Case 1: If no dynamic memory allocation in the derived class, no special operations are needed

    Case 2: if dynamic memory is allocated in the derived class, you should redefine a copy constructor and an assignment operator.

    1. class MyMap: pubic MyString
    2. {
    3. char * keyname;
    4. public:
    5. MyMap(const char * key, const char * value)
    6. {
    7. ...
    8. }
    9. MyMap(const MyMap & mm): MyString(mm.buf_len, mm.characters)
    10. {
    11. //allocate memory for keyname
    12. //and hard copy from mm to *this
    13. }
    14. MyMap & operator=(const MyMap &mm)
    15. {
    16. MyString::operator=(mm);
    17. //allocate memory for keyname
    18. //and hard copy from mm to *this
    19. return *this;
    20. }
    21. };