| Date Assigned: | Fri Jan-26 |
| Date Due: | Mon Jan-29 |
For this assignment, you will need the code in PriorityQueue.zip. This is the code we developed in class. As such, it is not properly commented, but it is reasonably well structured and serves as a good study guide.
1. Study this code for a quiz on Monday on Trees, Priority Queues, and Templates. Be sure to study each of these 3 topics.
2. Modify this code to verify that it correctly deletes every object that it creates (via "new") in the heap. Do this as follows:
2a) Modify the class Integer so that it includes (as a static) a count of the instances of that class. The constructor should increment this count, the destructor should decrement the count -- each time the count decrements back to 0, the destructor should also print out a message indicating that there are no more instances of Integer.
2b) Create a subclass of apstring, String, which does the same counting of instances as just described. Change your PriorityQueue<apstring> to be a PriorityQueue<String> so that you get the instance counting for strings, too.
2c) Add a command to your main program, 'm' for makeEmpty, which calls makeEmpty on the appropriate PriorityQueue. Of course, unless it was already empty, this should result in a message from that PriorityQueue's itemType class indicating that that class has no more instances.
Have a great weekend!
DK