unhandled exception - access violation reading location
i'm getting this error when i run my program:
Unhandled exception at 0x003f186f in Lab 8.exe: 0xC0000005: Access violation reading location 0x00000008.
here's the of code that i'm being told is where the error is (the line is in bold where the error is):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
double DoubleList::deleteMostRecent()
{
if(head == NULL)
{
return NULL;
}
else if(head->next == NULL)
{
double value = head->data;
delete head;
head = NULL;
return value;
}
else
{
DoubleListNode *secondLastNode;
secondLastNode = head;
while(head->next->next != NULL)
{
secondLastNode = secondLastNode->next;
}
DoubleListNode *lastNode = secondLastNode->next;
double value = lastNode->data;
delete lastNode;
secondLastNode->next=NULL;
return value;
}
}
|
Could someone explain this further to me and offer a possible fix?
Topic archived. No new replies allowed.