Hi, i am wri
Code:
delete current;
current=0;
ting a linked list and i would like to know how to delete a pointer that was not created with new.I have tried delete but it does not work.I know that in c , i use free();
Code:
void LinkedListCollection::remove(int item){
intListElement *previous;
intListElement *current;
current=this->head_;
if(lookup(item==1))
{
/*incase the item is in the head
*/
if(current->num==item)
this->head_=this->head_->next;
else
{
previous=current;
current=current->next;
while(current!=0)
{
if(current->num==item)
{
//i would like to delete my current but it wont work for me
previous->next=current->next;
//delete current;
current=0;
}
else
previous=current;
current=current->next;
}
}//else
}//if
}