C++



Circular and Doubly. Write each class in it’s own separate header file, Circular.h and Doubly.h. The following methods serve the same purpose for both classes: constructor – initializes pointers in the class to NULL; copy constructor – sets pointers to NULL and calls the overloaded assignment operator. overloaded assignment operator – performs a node by node copy of one object to another. overloaded == operator – returns true if both objects have the same number of nodes, and each object’s nodes have the same values respective of each other, false otherwise. overloaded < operator – performs a node-by-node comparison. returns true if the first object has fewer nodes or if any value in each respective node is less than the second object., false otherwise. destructor – destroys the linked list nodes. clear – destroys the linked list nodes, resetting pointers to NULL. insert – inserts it’s argument into the list, maintaining an ascending order. Returns 0 on success, -1 on failure. remove – remove’s the node containing it’s argument from the list. Returns 0 on success, -1 on failure. isFull – returns true if the list is full, false otherwise. isEmpty – returns true if the list is empty, false otherwise. print – displays the content of the list to the screen on a single line. Each value is separated by a space. In addition to the above methods, each class has a unique method as described below: In class Circular: getNext – assigns to it’s reference parameter the value of the node the q pointer currently points to. It then moves q to the next node in the list. Returns 0 on success, -1 on failure. In class Doubly: reverse – like print, but the values of the list are displayed in reverse order. Each class has two pointers, p and q, but the pointers serve different functions. In class Circular: p – serves as the “head” of the circular list. q – serves as the “current” pointer. This is used by getNext. In class Doubly: p – serves as the “head” of the doubly linked list. q – serves as the “tail” of the double linked list. It contains the address of last node in the list