Question: Create a Queue.cnn . Queue.cpp contains the member function implementations for Queue.h . Queue.h: class Queue { public: Queue ( ) ; / / ctor
Create a Queue.cnn Queue.cpp contains the member function implementations for Queue.h
Queue.h:
class Queue
public:
Queue; ctor inits a new empty Queue
~Queue; dtor erases any remaining QueueItems
void addItemchar pData;
void removeItem;
void print;
void erase;
private:
QueueItempHead; always points to first QueueItem in the list
QueueItempTail; always points to last QueueItem in the list
int itemCounter; always increasing for a unique id to assign to each new QueueItem
; end definitionclass Queue
The Queue class member functions should not have access to the private members of QueueItem objects. They call the public member functions of QueueItem.
As an example, the outline of the Queue::addItem member function is shown below. It must add a new QueueItem at the tail of the Queue, and update the pTail pointer to point to it The first item placed in the Queue becomes both the head and the tail of the list.:
The removeItem method removes the head QueueItem from the queue, and should release the memory using the C delete operator. It updates pHead to point at the following item if any as the new head. If the list becomes empty, both pHead and pTail must be set to null It does not change the value of itemCounter which is always incremented when a new item is added If called on an empty Queue, it does nothing.
The erase method removes all the items in the queue and should release the memory. To implement, you could loop calling removeItem until the queue is empty.
The Queue destructor should ensure that all items are removed from the queue. The easiest way is to call the erase method from the destructor.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
