////////////////////////////////////////////////////////////////////////////// ////////////////////////////// listdriver.cpp ////////////////////////////// ////////////////////////////////////////////////////////////////////////////// // Driver for simple linked list #include "list.h" // to compile under unix/linux: g++ nodedata.cpp list.cpp listdriver.cpp main() { NodeData* ptr; List mylist; // create file object and open the datafile ifstream infile("list.data"); if (!infile) { cerr << "File could not be opened." << endl; return 1; } // build list from data file mylist.buildList(infile); // now get node data from user and insert ptr = new NodeData; if (ptr == NULL) return 1; ptr->setData(); mylist.insert(ptr); // insert another node where data is pre-determined ptr = new NodeData(1000,'z'); mylist.insert(ptr); // print, sorted by number cout << endl << mylist << endl; cout << "Now let's print the list again, backwards." << endl; mylist.printBackwards(); cout << endl; return 0; }