#include #include "ListElem.h" // Need ListElem to define List #include "List.h" // Always include declarations first ! // ************************************************* // Constructor // ************************************************ List::List() { head = NULL; // Start with empty list } // ************************************************* // deleteElem(): delete at head // ************************************************* void List::deleteElem() { ListElem * p2; if ( head != NULL ) { p2 = head; head = p2->next; // The second is the new "first element" } } // ------------------------------- // insert(v): insert at head // ------------------------------- void List::insertElem(ListElem * elem) { elem->next = head; // Link new element head = elem; } void List::printList() { ListElem * p; p = head; cout << "List: "; while ( p != NULL ) { cout << p->value << " "; p = p->next; } cout << endl; }