The stub of append() should look like this:
void LinkedQueue::append(const Item& it) {
}
The append() method should behave as follows:
-
Try the following:
- Allocate a new Node containing (it, nullptr), and store its address in a local variable nPtr.
Catch the std::bad_alloc exception it might throw;
if that occurs, throw a FullQueueException.
- If the queue is empty:
- Make myFirstPtr point at the new node.
Otherwise:
- Make the myNextPtr member of the last node
(the node whose address is in myLastPtr) point at the new node.
- Make myLastPtr point at the new node.
- Increment mySize.