Hello,
Please i really need your help.
I am trying writing a code that will delete the last element of the list. However, i keep getting 0 or when i tweak it, i get a message asking me to abort what i am doing.
In this code, i append some values to the list and ask it to do some functions like get first, get last, remove first...these functions work fine. However, i cannot seem to get the remLast right.
thank you very much in advance.
Here is the code:
int LList::remLast()//this does not have parameters.
{
if(size==0){
cout<<"Empty List --- Removal is not";
cout<<"Possible --- Error"<<endl;
return -1;
}
Lnode *ptemp;
Lnode *temp=tail;;
if(size==1)
head=tail=NULL;
ptemp->next = temp->next;
size--;
if(tail==temp)
tail = ptemp;
delete temp;
}