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 operator = needs a reference argument rather than a value argument. When we use a value argument, a copy of the argument is made for the use of the called function. 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 within themselves, it isn't sufficient for objects that contain ...
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