Question: We are going to develop and implement a class PQ (priority queue) using the vector STL. The class should work for any data type that

We are going to develop and implement a class PQ (priority queue) using the vector STL. The class should work for any data type that supports the < operator. The class should have the following :

-Two constructors : one is the default constructor which creates an empty vector - the second constructor accepts a vector and sorts it in non-decreasing order.

-An accessor function to return the size of the queue.

-An accessor function to return the front of the list.

-An accessor function to print the entire queue.

-A mutator function to add an element to the queue keeping the list ordered.

-A mutator function to remove the front of the queue.

-NOW FOLLOW THE STEPS BELOW-

First create the interface for the class along with function stuns. The sort function should be in the private section since it will only be used by a constructor.

Add stubs for each member function and test the compilation (c++ -c).

Write the functions and test the compilation.

Write a main program that tests the class functions. (Use the pseudo-random number generator to create a vector and to add values to the queue.)

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!