c++ - 调试帮助 : C++ error

标签 c++ debugging

我收到这个错误:

SortedList.cpp:197: error: expected constructor, destructor, or type conversion before '*' token

这是代码:

197    Listnode *SortedList::copyList(Listnode *L) {
198        Listnode *current = L;
199
200        Listnode *copy = new Listnode;
201        copy->student = new Student(*current->student);
202        copy->next = NULL;
203
204        Listnode *head = copy;
205
206        current = current->next;
207        while (current != NULL) {
208            copy = copy->next = new Listnode;
209            copy->student = new Student(*current->student);
210            copy->next = NULL;
211        }
212        return head;
213    }

这是列表节点:

struct Listnode {
    Student *student;
    Listnode *next;
};
Listnode *head;

不确定我应该做什么。如果需要查看,我已经实现了构造函数和析构函数。任何关于问题可能是什么的见解都会有所帮助。

最佳答案

从注释 ListNode 看来是一个嵌套类,您需要使用以下内容: SortedList::Listnode *SortedList::copyList(SortedList::Listnode *L) 如果 copyList 是公开的,您可能还需要将其设为 public

关于c++ - 调试帮助 : C++ error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10099467/

相关文章:

ios - 这个错误是 Xcode 7 或 swift 2 中的错误吗?

c++ - 无法调用函数

C++传递一个函数作为参数,在某个点执行

c++ - 在 x64 windows 上启用 unicode regex 构建 boost

debugging - 如何在 WebStorm 中调试 Deno 应用程序

xcode - 尝试运行 Node.js 服务器时 vecLib 出现问题。

debugging - Intellij,Gradle:无法打开调试器端口(127.0.0.1:57850):java.net.SocketException “Socket closed”

python - 关于 Python 元组的不变性

c++ - 指向 QMainWindow 改变的指针

java - Android Studio(引用对象)