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
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started