Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lab05. //-------------------------------------------------------------------- // // Laboratory 5 ListLinked.h // // Class declaration for the linked implementation.

Similar presentations


Presentation on theme: "Lab05. //-------------------------------------------------------------------- // // Laboratory 5 ListLinked.h // // Class declaration for the linked implementation."— Presentation transcript:

1 Lab05

2 //-------------------------------------------------------------------- // // Laboratory 5 ListLinked.h // // Class declaration for the linked implementation of the List ADT // //-------------------------------------------------------------------- #ifndef LISTLINKED_H #define LISTLINKED_H #include using namespace std; template class List { public: List(int ignored = 0); List(const List& other); List& operator=(const List& other); ~List(); void insert(const DataType& newDataItem) throw (logic_error); void remove() throw (logic_error); void replace(const DataType& newDataItem) throw (logic_error); void clear(); bool isEmpty() const; bool isFull() const; void gotoBeginning() throw (logic_error); void gotoEnd() throw (logic_error); bool gotoNext() throw (logic_error); bool gotoPrior() throw (logic_error); DataType getCursor() const throw (logic_error); // Programming exercise 2 void moveToBeginning () throw (logic_error); // Programming exercise 3 void insertBefore(const DataType& newDataItem) throw (logic_error); void showStructure() const; private: class ListNode { public: ListNode(const DataType& nodeData, ListNode* nextPtr); DataType dataItem; ListNode* next; }; ListNode* head; ListNode* cursor; }; #endif

3 template List ::ListNode::ListNode(const DataType& nodeData, ListNode* nextPtr) // Creates a list node containing item elem and next pointer // nextPtr. : dataItem(nodeData), next(nextPtr) { }

4 head = new ListNode(newDataItem, NULL); Note: No template necessary in this allocation statement Lab Book (page 63) has the template and it should not.


Download ppt "Lab05. //-------------------------------------------------------------------- // // Laboratory 5 ListLinked.h // // Class declaration for the linked implementation."

Similar presentations


Ads by Google