void List::removeDup()
{
Node *after = NULL;
Node *dup = NULL;
curr = head;
while(curr->next != NULL)
{
after = curr->next; //node after current one
while(after != NULL)
{
if(curr->data == after->data) //if dup found
{
dup = after;
curr->next = after->next;
delete dup;
}
else
{
after = after->next;
}//if no dup found, advance after node
}
curr = curr->next; //advance curr node
}
}
This code uses the first node and compares with the rest to find duplicates. If found, it is deleted. The error I'm getting is
pointer being freed was not allocated. Does anyone know what this means?
Any help would be appreciated