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
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
Get step-by-step solutions from verified subject matter experts
