Now with the above functions it would be pretty simple to plug in the code for your restaurant program
struct restaurant
{
restaurant() {number = 0;}
restaurant(string nm, int n) {name = nm; number = n;}
void SayHello() {cout << "Hello, I'm " << name << "\n"; }
std::string GetName() {return name;}
int number;
std::string name;
struct node* registers;
};
int main()
{
struct node* head = NULL;
int nRestaurants = 0;
cout << "Enter the number of restaurants that you want\n";
cin >> nRestaurants;
cin.ignore();
for(int i = 0; i < nRestaurants; i++)
{
stringstream str;
str << "Wendy's #";
str << i+1;
string name = str.str();
struct restaurant* item = new struct restaurant(name, i+1);
InsertTail(&head, item);
}
struct node* n = head;
while( n != NULL)
{
cout << ((struct restaurant *)n->data)->GetName() << "\n";
n = n->next;
}
int number = 0;
cout << "Which node to you want (1-5) ?\n";
cin >> number;
n = GetItem(head, number-1);
((struct restaurant *)n->data)->SayHello();
DeleteList(&head);
}