lab9 - #include #include #include #include # #include...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include "datadefn.h" #include "ListType.h" #include <iostream> #include <cstddef> #include <fstream> # using namespace std; u struct NodeType; //forward declaration / typedef NodeType* NodePtr; t struct NodeType { ItemType item; NodePtr next; }; } List::List() //Post: listPtr is set to NULL. { listPtr = NULL; } //Copy-constructor for ListType. { NodeType* ptr1; NodeType* ptr2; N if(otherList.listPtr == NULL) listPtr = NULL; else { listPtr = new NodeType; listPtr->item = otherList.listPtr->item; ptr1 = otherList.listPtr->next; ptr2 = listPtr; while( ptr1 != NULL) { ptr2->next = new NodeType; ptr2 = ptr2->next; ptr2->item = ptr1->item; ptr1 = ptr1->next; } ptr2->next = NULL; } } bool List::IsThere(ItemType item) const //Post: If item is in the list IsThere is True; False otherwise. { bool moreToSearch; NodeType* location; N location = listPtr; bool found = false; moreToSearch = (location != NULL);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
m while(moreToSearch) { if(location->item > item) { location = location->next;
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

lab9 - #include #include #include #include # #include...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online