我想创建一个链接列表来下载一个txt文件,并使用链表来逐行处理文件。处理下载的链接列表操作时,将对其执行操作,例如文本编辑器。 但是我遇到了一些问题。看起来即使没有参数的原始Node()声明通过,代码段的“节点(字符串值)”部分也有问题。我无法弄清楚它是什么。C++链接列表
Node.h
class Node
{
public:
Node();
Node(string value);
void setNext(Node *nextNode); // Allows the user to set where the "next" pointer of a node points
friend class LinkedList;
private:
string data; // Data box
Node* next; // Pointer box
};
Node.cpp
# include <string>
# include "Node.h"
using namespace std;
Node::Node()
{
data = "";
next = NULL;
}
Node::Node(string value)
{
data = value;
next = NULL;
}
void Node::setNext(Node *nextNode) // Allows the user to set where the "next" pointer of a node points
{
this->next = nextNode;
}
请比 “一些问题” 和 “不对劲” 更具体。它不会编译?它会崩溃吗?它是否在您的终端上打印“0x3434”?它报警并报告你失踪了吗? – molbdnilo
@molbdnilo,可能只是在SO上发布随机问题? ;) – SergeyA
给出以下错误: 缺少类型说明符 - int假定。行:17 'data':未知的重写说明符行:17 – Blake