Write the following three source files in C++: • StringList.h – In this file, you declare a class named StringList. – St
Posted: Tue Jul 12, 2022 8:09 am
Write the following three source files in C++:• StringList.h– In this file, you declare a class named StringList.– StringList is a modified version of NumberList class (Chapter18), and is designed to store C++ stringsin a linked list.– Therefore, each node must store a string, not a number.– The node structure must be declared within class, and a privateattribute head points to the starting node.– The class provides a default constructor that creates an emptylinked list, and a destructor that releasesall the nodes.– The class also provides public member functions for inserting anddeleting a node (see below for details).– It also provides a public member function for displaying thelist.• StringList.cpp– In this file, you provide definitions for the default constructorand the destructor for StringList.– Make sure the destructor visits every node in the list anddeletes every one of them from the heap.– Define insertFront function to insert a new node into the frontof the list. Therefore, the new node willbe the new first node in the list. This function takes a string asa parameter.– Define insertBack function to insert a new node into the back ofthe list. Therefore, the new node will bethe new last node in the list. This function takes a string as aparameter.– Define deleteFront function to delete the first node from thelist. This function takes no parameter.– Define deleteBack function to delete the last node from the list.This function takes no parameter.– Define display function that displays the current contents(strings) of the list (display strings in a singleline, separated by a space). This function takes noparameter.• hw5.cpp– In this file, you define main function that tests StringListclass.– You must first create a StringList object.– Then start inserting new nodes, one at a time. Alternate betweeninserting into the front and into theback. Make sure to add at least 6 nodes.
– Then start deleting nodes, one at a time. Alternate betweendeleting from the front and from the back.– Make sure all the nodes are deleted before terminating theprogram.– After each insertion or deletion, call display member function todisplay the updated list.– Make sure all the member functions are tested and shown to workproperly, without missing any of them.– Note that the display function must be called pretty much everytime a node is inserted or deleted. Oth-erwise the respective functionality will not be properlydemonstrated and could incur point deduction.– Also note that each member function should properly workregardless of the current list configuration(empty list, one-node list, or multiple-node list).Example run:Now inserting...Inserting Node in Front: ThorInserting Node in Back : Thor Black WidowInserting Node in Front: Iron Man Thor Black WidowInserting Node in Back : Iron Man Thor Black Widow WonderWomanInserting Node in Front: Black Panther Iron Man Thor Black WidowWonder WomanInserting Node in Back : Black Panther Iron Man Thor Black WidowWonder Woman Captain AmericaInserting Node in Front: Hulk Black Panther Iron Man Thor BlackWidow Wonder Woman Captain AmericaThe full string: Hulk Black Panther Iron Man Thor Black WidowWonder Woman Captain AmericaNow deleting...Deleting Back Node : Hulk Black Panther Iron Man Thor Black WidowWonder WomanDeleting Front Node: Black Panther Iron Man Thor Black Widow WonderWomanDeleting Back Node : Black Panther Iron Man Thor Black WidowDeleting Front Node: Iron Man Thor Black WidowDeleting Back Node : Iron Man ThorDeleting Front Node: ThorDeleting Back Node :All nodes have been deleted.
– Then start deleting nodes, one at a time. Alternate betweendeleting from the front and from the back.– Make sure all the nodes are deleted before terminating theprogram.– After each insertion or deletion, call display member function todisplay the updated list.– Make sure all the member functions are tested and shown to workproperly, without missing any of them.– Note that the display function must be called pretty much everytime a node is inserted or deleted. Oth-erwise the respective functionality will not be properlydemonstrated and could incur point deduction.– Also note that each member function should properly workregardless of the current list configuration(empty list, one-node list, or multiple-node list).Example run:Now inserting...Inserting Node in Front: ThorInserting Node in Back : Thor Black WidowInserting Node in Front: Iron Man Thor Black WidowInserting Node in Back : Iron Man Thor Black Widow WonderWomanInserting Node in Front: Black Panther Iron Man Thor Black WidowWonder WomanInserting Node in Back : Black Panther Iron Man Thor Black WidowWonder Woman Captain AmericaInserting Node in Front: Hulk Black Panther Iron Man Thor BlackWidow Wonder Woman Captain AmericaThe full string: Hulk Black Panther Iron Man Thor Black WidowWonder Woman Captain AmericaNow deleting...Deleting Back Node : Hulk Black Panther Iron Man Thor Black WidowWonder WomanDeleting Front Node: Black Panther Iron Man Thor Black Widow WonderWomanDeleting Back Node : Black Panther Iron Man Thor Black WidowDeleting Front Node: Iron Man Thor Black WidowDeleting Back Node : Iron Man ThorDeleting Front Node: ThorDeleting Back Node :All nodes have been deleted.