The save and remove Members

Aside from copy control, the Message class has only two public members: save, which puts the Message in the given Folder, and remove, which takes it out:

void Message::save(Folder &f){    folders.insert(&f); // add the given Folder to our list of Folders    f.addMsg(this);     // add this Message to f's set of Messages}void Message::remove(Folder &f){    folders.erase(&f); // take the given Folder out of our list of Folders    f.remMsg(this);    // remove this Message to f's set of Messages}

To save (or remove) a Message requires updating the folders member of the Message. When we save a Message, we store a pointer to the given Folder; when we remove a Message, we remove that pointer.

These operations must also update ...

Get C++ Primer, Fifth Edition 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.