hey,
i've been trying to insert the element in the linked list, but I don't understand why the element is inserted at some other position i.e. it is not inserted at the position which i pass.
is there any error in the insert function?
template <class T>
void insert ( int pos , T y) // passing position of element and element to be inserted
{
int c = 0;
node<T> *tmp;
node<T> *curr= new node;
while ( c < pos )
{
tmp = tmp -> next;
c++;
}
curr -> item = y;
curr -> next = tmp -> next;
tmp -> next = curr;
}