Code for the push_back() Function
//-----------------------------------------------------
// push_back
//
// Insert the specified item at the end of the list.
//
// In Parameter: item
//-----------------------------------------------------
void push_back(const itemType& item)
{
node* temp;
node* ptr;
try
{
ptr = new node;
ptr->info = item;
ptr->next = NULL;
if (head == NULL)
{
head = ptr;
}
else
{
temp = head;
while (temp->next != NULL)
{
temp = temp->next;
}
temp->next = ptr;
}
n++;
}
catch (bad_alloc bae)
{
cout << "Memory Allocation Failure (" << bae.what() << ")\n\n";
exit(0);
}
}