Академический Документы
Профессиональный Документы
Культура Документы
#define _LINKEDLIST_H
#include <string>
struct Node
{
string agentName;
int caseNo;
string caseDesc;
Node * next;
Node (const string& name, const int no , const string& desc, Node * nptr)
: agentName(name),
caseNo(no),
caseDesc(desc),
next(nptr)
{
}
};
class LinkedList
{
public:
LinkedList(); // constructor
~LinkedList(); // destructor
int size() const;
void addToStart(Node *) ;
void addToEnd(Node *) ;
void printList() ;
void removeNodeAt(int );
private:
#endif
#include "linkedlist.h"
LinkedList::LinkedList()
: myHead(new Node("dummy",0,"dummy",0)),
myTail(myHead),
mySize(0)
// post: internal list is empty, one header node allocated
{
}
~LinkedList(){
// write your code for releasing memory here...
}
{
return mySize;
}
{
// Write your code here mySize++;
}
#include <iostream>
#include <stdlib.h>
#include <conio.h>
#include "linkedlist.h"
int main(int argc, char *argv[])
{
LinkedList myList;
Node *node ;
int choice = 0 , index=0 ;
string agentName, caseDesc ;
int caseNo;
do
{
cout<< "\n Enter 1 Add a new node to the end \n";
cout<< " Enter 2 Add a new node to the beginning \n";
cout<< " Enter 3 Print out the entire list \n";
cout<< " Enter 4 Remove a node from the list \n";
cout<< " Enter 5 Quit the program \n";
cout<< " Enter your choice : ";
cin>> choice;
switch(choice){
case 1:
// Insert appropriate code here ....
break;
case 2:
// Insert appropriate code here ....
break;
case 3:
// Insert appropriate code here ....
break;
case 4:
// Insert appropriate code here ....
break;
case 5:
exit(1);
break;
default :
cout<<"\n Invalid Option, Please try again .....\n";
break;
}
}while (true);