// File: Simple.cpp // Manual construction of an ordered linked list // - demonstrates four insertion cases // - list traversal for printing // - manual deletion. #include #include "Node.h" using namespace std; void print(node *p) { while (p!=NULL) { cout << p -> data << ", "; p = p -> next; } } int main() { node *first; // Insert to empty list first = new node(10); // Use default for link // Insert at end first -> next = new node(20); // Insert at head of list first = new node(5,first); // Now it's safe to change first // Insert in middle first -> next -> next = new node(15,first -> next -> next); print(first); node *temp = first -> next -> next; first -> next -> next = first -> next -> next -> next; delete temp; print(first); }