首页 > 解决方案 > 错误:“系统找不到指定的文件”。在实现循环链​​表时

问题描述

我正在解决一些链表问题并遇到错误“系统找不到指定的文件”。让我简单介绍一下问题。为了在单链表中插入元素,我使用了以下命令:

     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;
     }

编写此代码后,编译器抛出错误“系统找不到指定的文件”。请帮忙。

标签: c++pointersdata-structuressingly-linked-list

解决方案


推荐阅读