CS2401 Lab Assignment 11


Category: You will Instantly receive a download link for .zip solution file upon Payment


5/5 - (5 votes)

For this assignment you are to use the STL queue and priority queue classes. You can do this with #include .
Create a class for a single chore. This class will have two attributes, a string describing what the chore is, and a priority number, with the highest number being the item that is most urgent. Overload the < operator so that it returns whatever the comparison of the priority levels is. Your class should have input and output functions as well, allowing the chore and its priority level to be input from the keyboard and output to the screen. Now in the main declare an STL queue of chore. (Note: You are declaring a queue of chores, not pointers to chores.) You will also need a temp chore to handle input. Now start a little loop and type in five chores, along with their priority level. This will involve calling temp.input(); (OR cin>>temp; // depending on how you’ve done your chore input), and then q.push(temp); Note that the queue only allows you to push to one end. Once you have finished your output loop have a loop that outputs all the chores in the queue.