Please help,This is a c++ dealing with Inheritance create four classes with the
ID: 659411 • Letter: P
Question
Please help,This is a c++ dealing with Inheritance
create four classes with the corresponding header and implementation files as well as a test file that contains the main function.
Write separate functions in main file to test each individual class. create a doubly linked list that contains a head and tail node as member variables. create two derived classes called Stack and Queue that use the doubly linked list as a base class.
A Node class that allows user to store a name and stores a reference to the previous and the next node. Provide a constructor, overloaded constructor and setters/getters for the member variables. Make your member variables private. Validate the parameter name to make sure that it is not NULL or less than 3 characters long. If it is, display a message and return from the function. You may use a string object to store the name.
A List class that represents a doubly linked list with a reference to the front and the back node of the list. Provide a default and overloaded constructor that takes name as the parameter. Provide addFirst, addLast, removeFirst and removeLast functions to allow for addition and removal of nodes. Provide a size function that returns the size of the list as well as an isEmpty function that returns true or false.
Overload << operator to print the contents of the stack. The function pop should output that the stack is empty if you call the function on an empty stack.
A Queue class that inherits from the List class. Provide enqueue, dequeue functions that follow the queue policy. Overload << operator to print the contents of the queue. Thefunction dequeue should output that the queue is empty if you call the function on an empty queue. Overloading << operator with inheritance will pose a problem since it is a friend function. A way to get around this problem is to provide a virtual member function that will print the corresponding class members (to ostream) in the base class and the corresponding derived classes. This member function can then be called from the operator function.
Explanation / Answer
main.cpp