#include <iostream>
using namespace std;
struct node
{
int data;
node* next;
};
class link_list
{
node* first;
node* last;
public:
link_list()
{
first=last = NULL;
}
~link_list()
{
// frees up memory allocated by new
node* current = first;
node* next;
while (current != NULL)
{
next = current->next;
delete current;
current = next;
}
}
bool IsEmpty()
{
if(first == NULL)
return true;
else
return false;
}
void AddItem(int data)
{
node *temp = new node;
temp->data = data;
temp->next = NULL;
if(first == NULL)
first = last = temp;
else
last->next = temp;
last = temp;
}
void Display()
{
node *current = first;
int i=1;
while(current!=NULL)
{
cout<<i<<" - "<<current->data<<endl;
current=current->next;
i++;
}
}
};