我收到这个错误:
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/