void DLinkedList::removeName(const Elem& name) {
DNode * node = header;
if (node != NULL) {
do {
if(node->elem == name){
node->prev->next = node->next;
node->next->prev = node->prev;
delete node;
}
node = node->next;
} while (node != header); // Stop when we reach the head again.
}
}
我将它扔到调试器中,在我大约第三次通过 if(node->elem == name) 之后,它由于我不太确定的原因而崩溃。