13.4. A Copy-Control Example
Although copy control is most often needed for classes that allocate resources, resource management is not the only reason why a class might need to define these members. Some classes have bookkeeping or other actions that the copy-control members must perform.
As an example of a class that needs copy control in order to do some bookkeeping, we’ll sketch out two classes that might be used in a mail-handling application. These classes,
Folder, represent, respectively, email (or other kinds of) messages, and directories in which a message might appear. Each
Message can appear in multiple
Folders. However, there will be only one copy of the contents of any given
Message. That way, if the contents of a