Special Member Functions
The problems with the StringBad class stem from special member functions. These are member functions that are defined automatically. In the case of StringBad, the behavior of these member functions is inappropriate to this particular class design. In particular, C++ automatically provides the following member functions:
• A default constructor if you define no constructors
• A default destructor if you don’t define one
• A copy constructor if you don’t define one
• An assignment operator if you don’t define one
• An address operator if you don’t define one
More precisely, the compiler generates definitions for the last three items if a program uses objects in such a way as to require them. For example, if you assign one ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access