我正在尝试从链接列表中删除。但如果我尝试删除第一个元素,它似乎不起作用。
if (found)
{
if (prev == NULL)
{
prev = head;
prev -> next = curr -> next;
delete curr;
}
else
{
prev -> next = curr -> next;
delete curr;
}
}
return found;
如果我要从中间或尾部的某处删除,findNode 函数会起作用。但我发现如果我从尾部删除,我必须将 next 设置为 NULL,对吗?