its a menu driven program. the user enters 1 to insert element and 2 to display.
after I entered more than 1 element.and pressed 2 to display it only dislayed the first element.please help me with this. thanks...
#include<iostream>
using namespace std;
class link_list
{
int data;
link_list *next;
public:
link_list()
{
data = 0;
next = NULL;
}
link_list(int num)
{
data = num;
next = NULL;
}
~link_list(){}
void insert(link_list *node);
friend void display(link_list *);
};
void link_list::insert(link_list *node)
{
link_list *last ;
last = node;
while(last->next != NULL)// until next of last is not null
{
last->next = node; // next of last becomes equal to node
last = last->next;
// last jumps to next
}
}