C +中的Linkedlist节点

0 c++ linked-list

我正在学习一本关于数据结构的书,并在链表示例中编译了他们的节点,我收到了这个错误:

 and Everything.cpp|7|error: expected unqualified-id before "int"|
 and Everything.cpp|7|error: expected `)' before "int"|
||=== Build finished: 2 errors, 0 warnings ===|
Run Code Online (Sandbox Code Playgroud)

该节点的代码是:

typedef struct Node
{
    struct Node(int data)    //Compile suggest problem is here
    {
        this-> data = data;
        previous = NULL;
        next = NULL;
    }
    int data;
    struct Node* previous;
    struct Node* next;
} NODE;
Run Code Online (Sandbox Code Playgroud)

我不熟悉结构,我正在使用Code :: blocks进行编译.有谁知道什么是错的?

Ada*_*eld 5

代码示例错误.struct构造函数声明前面不应该有关键字.它应该是:

typedef struct Node
{
    Node(int data)  // No 'struct' here
    {
        this-> data = data;
        previous = NULL;
        next = NULL;
    }
    int data;
    struct Node* previous;
    struct Node* next;
} NODE;
Run Code Online (Sandbox Code Playgroud)