Can someone please tell me why I might be getting a access violation when doing the following for a double linked list:
~DLList()
{
while(!isEmpty()) //isEmpty is working..
removeHead();
}
bool isEmpty()
{
if(head == NULL && tail == NULL)
return true;
else
return false;
}
char * removeHead()
{
if(!isEmpty())
{
ListNode<char *> *temp = head;
char * tempData = temp->data;
cout << temp->data;
if(head == tail)
head = tail = NULL;
else {
head = head->next;
head->previous = NULL;
}
if(temp != NULL && temp->data != NULL){
delete temp; //--->breaks here
}
length--;
return tempData;
} else
exit(1);
}