Question: 5. Error Testing The DynIntstack and DynIntQueue classes shown in this chapter are abstract data types using a dynamic stack and dynamic queue, respectively. The

5. Error Testing The DynIntstack and DynIntQueue classes shown in this chapter are abstract data types using a dynamic stack and dynamic queue, respectively. The classes do not currently test for memory allocaton errors. Modify the classes so they determine if new nodes cannot be created, and handle the error condition in an appropriate way. (You will need to catch the predefined exception bad_alloc.) NOTE: If you have already done Programming Challenges 2 and 4, modify the templates you created. 7. Queue Exceptions Modify the static queue class used in Program 18-5 as follows. Make the isFull member private. tion when the queue runs out of space. tion when the queue is empty. The exception handler for queue overflow should print an appropriate error message 1. 2. Define a queue overflow exception and modify enqueue so that it throws this excep- 3. Define a queue underflow exception and modify dequeue so that it throws this excep- 4. Rewrite the main program so that it catches overflow exceptions when they occur. and then terminate the program
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
