// file: list_00.cc // // include files // #include "List.h" // the implementation of the class List member functions // // method: default constructor // List::List() { // initialize the local data // head_d = (Node*)NULL; // exit gracefully // }; // method: default destructor // List::~List() { // loop over the list // while (head_d != (Node*)NULL) { Node* tmp = head_d->get_next(); delete head_d; head_d = tmp; } // clear the local data // head_d = (Node*)NULL; // exit gracefully // }; // method: display // void List::display(char* delim_a) { // print a delimiter // fprintf(stdout, "%s\n", delim_a); // loop over the list // Node* tmp = head_d; while(tmp != (Node*)NULL) { fprintf(stdout, " (%u) value = %d\n", tmp->get_next(), tmp->get_value()); tmp = tmp->get_next(); } // exit gracefully // }; // method: insert // void List::insert(int value_a) { // create a new node // Node* tmp = new Node; // add the value to the temporary node // tmp->put_value(value_a); // advance the list // tmp->put_next(head_d); head_d = tmp; // exit gracefully // };