#include #include #include using namespace std; class Strings { public: string s; Strings () { cout << "String object initialised\n"; } ~Strings () { cout << "String object destroyed \n"; } }; int main (int argc, char **argv) { int i = 1; list *myList; Strings currentArgument; list::iterator listitem, next, tmp; myList = new list(); /* create new list */ while (i < argc) { currentArgument.s = argv[i]; i++; cout << "The next argument is " << currentArgument.s <<"\n"; myList->push_front (currentArgument); } listitem = myList->begin(); while (listitem != myList->end()) { cout << "The following argument is" << listitem->s << "\n"; next = listitem; next++; listitem = next; } listitem = myList->begin(); listitem++; delete (myList); cout << "Trying to access a deleted list" << listitem->s << "\n"; i = 1; while (i < argc) { cout << "The next argument is " << argv[i] <<"\n"; i++; } exit (0); }