Destructors
•
OK, so what is wrong with this:
while (head) {
delete head;
head = head->next;
}
delete head;
•
Two things. We are accessing memory
within the loop that has already been
deallocated
•
Second, we have an extra “delete”