c++ - 错误:“系统找不到指定的文件”。在实现循环链表时
问题描述
我正在解决一些链表问题并遇到错误“系统找不到指定的文件”。让我简单介绍一下问题。为了在单链表中插入元素,我使用了以下命令:
class Node
{
public:
int data;
Node *next;
};
void insertBeg(Node **head_ref, int new_data)
{
Node *new_node = new Node();
new_node->data = new_data;
new_node->next = *head_ref;
*head_ref = new_node;
return;
}
int main()
{
Node *head = NULL;
insertBeg(&head,5);
insertBeg(&head,6);
}
这工作得很好。然后我尝试以类似的方式实现循环链表(对于链表为空的情况)。下面是相同的代码。
class Node
{
public:
int data;
Node *next;
};
void insertEmpty(Node *last_ref, int new_data)
{
Node *new_node = new Node();
new_node->data = new_data;
last_ref = new_node;
last_ref->next = last_ref;
return;
}
int main()
{
Node *last = NULL;
insertEmpty(last,5);
return 0;
}
编写此代码后,编译器抛出错误“系统找不到指定的文件”。请帮忙。
解决方案
推荐阅读
- sql - 用多个字符替换字符
- asp-classic - 经典 Asp 中的 Request.ServerVariables
- reactjs - React useReducer,调度未按预期工作
- html - 在表格交叉线上方的中心页面设置响应图像
- bash - 使用带有 -n 选项的 echo 命令不会打印变量
- angular - MatCheckbox 不检查手机
- entity-framework - 如何使用 Linq 在 .NET EF Core 中查询?
- dart - Vagrant 访问 Dart webdev 服务器
- pdf - 脚本 pdf atom 的 pdf 生成
- flutter - 将文本与坐标对齐(不在 y 轴上移动)