main.cpp

 //-----------------------------------------
//
// Coded by Richard Creary
//
// A simple Link List
//
// "List Class Test"
//
// main.cpp
//
//-----------------------------------------
#include <iostream.h>
#include <stdlib.h>
#include "list1.h"

//---------------------------------------
inline menu(){
cout << "\t\tLINKED LIST\n\n";
cout << "\t\t1. Insert in list.\n";
cout << "\t\t2. Delete from list.\n";
cout << "\t\t3. Print List.\n";
cout << "\t\t4. Exit\n";
}

//---------------------------------------
main()
{

List Lt;

int choice;
int item;

menu();
do {

cout << '?';
cin >> choice;

switch(choice){
case 1:
cout << "Enter a number to add to list.\n";
cin >> item;
Lt.Insert(item);
Lt.Print();
break;
case 2:
if (Lt.isEmpty()){
cout << "The list is empty.\n\n";
break;
}
else{
cout << "Enter a number to delete from list.\n";
cin >> item;
Lt.Delete(item);
Lt.Print();
break;
}
case 3:
Lt.Print();
break;

}
}while(choice != 4);
exit(0);
return 0;
}

Project Homepage: