且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从链接列表中删除节点(递归)

更新时间:2023-02-13 23:34:57

您正在考虑的唯一节点是当前节点,因此您必须具有修改 l 的规定:

The only node you're considering is the current one, so you must have a provision for modifying l:

if (current->data == data)
{
  l = current->next;
  delete current;
  return true;
}