First Review
After finishing most of the requirements to make the string class a concrete data type in the previous chapter, we went back to look at why the operator = needs a reference argument rather than a value argument. When we use a value argument, a copy of the argument is made. In the case of a user-defined data type, this copy is made via the copy constructor defined for that type. If we don't define our own copy constructor, the compiler will generate one for us, which will use memberwise copy; that is, simply copying all of the member variables in the object. While a memberwise copy is fine for simple objects whose data are wholly contained with themselves, it isn't sufficient for objects that contain pointers to data stored in other ...
Get Learning to Program in C++ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.