void deleteElement(LinkedListElement<char> *&pending)
{
if (pending->Next) {
char value = pending->Next->Data;
pending->Data = value;
LinkedListElement<char> *temp = pending->Next;
pending->Next = pending->Next->Next;
delete temp;
}else{
pending = NULL;
//pending =nullptr;
delete pending;
}
}
簡單刪除節點++ 我要問什麼是else語句,如果鏈表末端,這樣我就可以刪除myselft,我通過引用傳遞值(& ),但它不工作如何參照刪除自己用C
void deleteElement(LinkedListElement<char> *&pending)
{
if (pending->Next) {
char value = pending->Next->Data;
pending->Data = value;
LinkedListElement<char> *temp = pending->Next;
pending->Next = pending->Next->Next;
delete temp;
}else{
delete pending;
//pending = NULL;
}
}
我嘗試這種方式,但它總是給我的錯誤: 的malloc:*錯誤對象0x100103b40:被釋放的指針沒有被分配 *設置malloc_error_break斷點調試
「不起作用」是什麼意思? – djechlin