August 2012
Intermediate to advanced
976 pages
30h 17m
English
Message ClassWhen we copy a Message, the copy should appear in the same Folders as the original Message. As a result, we must traverse the set of Folder pointers adding a pointer to the new Message to each Folder that points to the original Message. Both the copy constructor and the copy-assignment operator will need to do this work, so we’ll define a function to do this common processing:
// add this Message to Folders that point to mvoid Message::add_to_Folders(const Message &m){ for (auto f : m.folders) // for each Folder that holds m f->addMsg(this); // add a pointer to this Message to that Folder}
Here we call addMsg on each Folder in m.folders. The addMsg function will add a pointer to this Message to that ...
Read now
Unlock full access