i'm having problems creating and implementing the final requirment:void remove_message(int i) const;
This is my question:
You have to create a class called mailbox. You don't yet know how to store a collection of message objects. Instead, use the following brute force approach: The mailbox contains one very long string, which is the concatenation of all messages. You can tell where a new message starts by searching for a From: at the beginning of a line. This may sound like a dumb strategy, but surprisingly, many e-mail systems do just that.
Implement the following member functions:
void Mailbox::add_message(Message m);
Message Mailbox::get_message(int i) const;
void remove_message(int i) const;
I would appreciate any input or comments anyone can make about what I have so far and if what I am doing or trying to do makes sense.
The code makes sense. The vector class lets you add messages to the end of the list efficiently. If this is the typical operation, the code makes sense. Removing a message in the middle of the vector might be expensive though.
However, this doesn't make sense:
void remove_message(int i) const
A member function that changes the object (removing a message in this case) should not be declared const.