Question: Define a template class named Queue that contains a list of any data type. For example Queue , Queue , Queue , Queue , etc

Define a template class named Queue that contains a list of any data type. For example Queue, Queue, Queue, Queue, etc ...In general Queue is special FIFO data structure (FIFO: First In First Out) that new elements will always be added to the end of the list (enqueue operations) and elements will always be removed from the beginning of the list (dequeue operations).

The following class definition is needed:

The class contains only one member data which is a STL vector of T elements.

Default constructor that does nothing but need to be defined.

Destructor is to remove all elements from the list.

Member function dequeue (takes no parameter) that removes the first element in the vector and returns it as function's return type. If the vector is empty throw Exception exception.

Member function enqueue (takes a template type object as its only parameter) that adds the object to the end of the vector

Member function count that returns the number of elements in the Queue

Finally show code to add three integers 10, 20, 30 to a Queue of integers. Then show code to remove those integers in the Queue using a loop (not to use new for loop syntax). Your code must be general that makes no assumption about how many elements are currently in the Queue. Display the integers after each remove. DO NOT WRITE THE ENTIRE PROGRAM. JUST A PIECE OF CODE

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!