#include #include #include #include #include "plist.h" List::~List() { listPointer temp; while (list != NULL) { temp = list; list = list->next; // unlink first item on list delete temp; // delete it temp = NULL; } } void List::Insert(int newValue) { listPointer temp = new listItem; assert (temp != NULL); temp->next = list; list = temp; temp->value = newValue; } int List::Delete(void) { listPointer temp; int returnVal; // value of first list item assert (list != NULL); returnVal = list->value; // get value of first list item temp = list; list = list->next; // unlink first list item delete temp; // delete first list item temp = NULL; return returnVal; } void List::Print(void) { for (listPointer i = list; i != NULL; i = i->next) cout << setw(10) << i->value << endl; }