Question: Description: In this exercise, you will implement an undo feature for a simple text editor using a stack. The undo feature should allow the userto

Description: In this exercise, you will implement an undo feature for a simple text editor using a stack. The undo feature should allow the userto undo the most recent edit operation. Requirements: Implement a class called TextEditor that utilizes a stack to store the edit history. The TextEditor class should have the following member functions: - void insert[const string& text): Inserts the given text into the editor and adds the edit operation to the stack. - void undot): Undoes the most recent edit operation by removing the last inserted text from the editor and the stack. If there are no edit operations to undo. print an appropriate message. - void printi): Prints the current text in the editor. - void cleari}: Clears the editor and removes all edit operations from the stack. Instructions for testing your program: - Implement the TextEditor class with the required memberfunchons. - Test the functionality of the TextEditor class by performing the following operations: - Insert the text "Hello, \" into the editor. - Insert the text "world!\" into the editor. - Printthe current text in the editor. - Undo the last edit operation. - Printthe current text in the editor. - Insert the text "Goodbye!\" into the editor. - Undo the last edit operation. - Undo the last edit operation again. - Printthe current text in the editor. - Clear the editor. - Printthe current text in the editor
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
