The stub of remove() should look like this:
Item LinkedQueue::remove() {
}
The remove() method should behave as follows:
- If the queue is empty, throw an EmptyQueueException;
- Otherwise:
- Store the item in the oldest node (the one pointed to by myFirstPtr) into local variable result;
- Save the address of the oldest node in a local variable nPtr;
- Make myFirstPtr point at the next-oldest node in the queue (or nullptr if there is none);
- Set the myNextPtr member of the oldest node to nullptr;
- Deallocate the oldest node;
- Subtract 1 from mySize;
- Return result.