C++ 错误c2953:创建双链接列表时出错

C++ 错误c2953:创建双链接列表时出错,c++,visual-c++,template-classes,C++,Visual C++,Template Classes,我有以下代码显示“Node.cpp”文件中的错误 #包括“stdafx.h” #包括 使用名称空间std; 模板//认为错误在这里 类节点 { 私人: X数据; 节点*prev,*next; 公众: 节点(X数据) { 这->数据=数据; prev=next=NULL; } ~Node(){} X getData() { 返回数据; } }; 这是双重列表文件 #include "stdafx.h" #include <iostream> #include "conio.h"

我有以下代码显示“Node.cpp”文件中的错误

#包括“stdafx.h”
#包括
使用名称空间std;
模板//认为错误在这里
类节点
{
私人:
X数据;
节点*prev,*next;
公众:
节点(X数据)
{
这->数据=数据;
prev=next=NULL;
}
~Node(){}
X getData()
{
返回数据;
}   
};
这是双重列表文件

#include "stdafx.h"
#include <iostream>
#include "conio.h"
#include "Node.cpp"

template<typename T>
class DoubleList
{
    private:
    public:
        Node *first, *last;

        DoubleList()
        {
            first=last=NULL;
        }
        ~DoubleList()
        {}
        void insertLast(T data)
        {
            Node *t=new Node(data)
            if(first==last)
            {
                 first=t;
            }
            last->next=t;
            t->prev=last;
            last=t;
            cout<<"\nNode having data ["<<data<<"] is inserted successfully";
        }

        void insertFirst(T data)
        {
            Node *t=new Node(data)
            if(first==last)
            {
                 first=t;
            }
            first->prev=t;
            t->next=first;
            first=t;
            cout<<"\nNode having data ["<<data<<"] is inserted successfully";
        }

        void display()
        {
            Node *t=first;
            cout<<"\nPrevious   Data    Next"
            while(t->next!=NULL)
            {
                cout<<t->prev<<"        "<<t->data<<"       "<<t->next<<endl;
                t=t->next;
            }
        }

};
#包括“stdafx.h”
#包括
#包括“conio.h”
#包括“Node.cpp”
模板
类双重列表
{
私人:
公众:
节点*第一个,*最后一个;
双重列表()
{
first=last=NULL;
}
~DoubleList()
{}
void insertLast(T数据)
{
Node*t=新节点(数据)
如果(第一个==最后一个)
{
第一个=t;
}
last->next=t;
t->prev=last;
last=t;

cout这将起作用。您有一些;缺少。您还应该使用nullptr而不是NULL。您还缺少一些模板参数

Node.h

#include "stdafx.h"
template<typename X>
class Node
{
private:
    X data;
    Node* prev, * next;
public:
    Node(X data)
    {
        this->data = data;
        prev = next = nullptr;
    }
    ~Node() {}
    X getData()
    {
        return data;
    }
};

#包括“stdafx.h”
模板
类节点
{
私人:
X数据;
节点*prev,*next;
公众:
节点(X数据)
{
这->数据=数据;
prev=next=nullptr;
}
~Node(){}
X getData()
{
返回数据;
}
};
双重名单

#include "stdafx.h"
#include <iostream>
#include "Node.h"

using namespace std;

template<typename T>
class DoubleList
{
private:
public:
    Node<T>* first, * last;

    DoubleList()
    {
        first = last = NULL;
    }
    ~DoubleList()
    {}
    void insertLast(T data)
    {
        Node* t = new Node(data);
        if (first == last)
        {
            first = t;
        }
        last->next = t;
        t->prev = last;
        last = t;
        cout << "\nNode having data [" << data << "] is inserted successfully";
    }

    void insertFirst(T data)
    {
        Node* t = new Node(data);
        if (first == last)
        {
            first = t;
        }
        first->prev = t;
        t->next = first;
        first = t;
        cout << "\nNode having data [" << data << "] is inserted successfully";
    }

    void display()
    {
        Node* t = first;
        cout << "\nPrevious   Data    Next";
        while (t->next != NULL)
        {
            cout << t->prev << "        " << t->data << "       " << t->next << endl;
            t = t->next;
        }
    }
};
#包括“stdafx.h”
#包括
#包括“Node.h”
使用名称空间std;
模板
类双重列表
{
私人:
公众:
节点*第一个,*最后一个;
双重列表()
{
first=last=NULL;
}
~DoubleList()
{}
void insertLast(T数据)
{
Node*t=新节点(数据);
如果(第一个==最后一个)
{
第一个=t;
}
last->next=t;
t->prev=last;
last=t;
库特
#include "stdafx.h"
#include <iostream>
#include "Node.h"

using namespace std;

template<typename T>
class DoubleList
{
private:
public:
    Node<T>* first, * last;

    DoubleList()
    {
        first = last = NULL;
    }
    ~DoubleList()
    {}
    void insertLast(T data)
    {
        Node* t = new Node(data);
        if (first == last)
        {
            first = t;
        }
        last->next = t;
        t->prev = last;
        last = t;
        cout << "\nNode having data [" << data << "] is inserted successfully";
    }

    void insertFirst(T data)
    {
        Node* t = new Node(data);
        if (first == last)
        {
            first = t;
        }
        first->prev = t;
        t->next = first;
        first = t;
        cout << "\nNode having data [" << data << "] is inserted successfully";
    }

    void display()
    {
        Node* t = first;
        cout << "\nPrevious   Data    Next";
        while (t->next != NULL)
        {
            cout << t->prev << "        " << t->data << "       " << t->next << endl;
            t = t->next;
        }
    }
};
#include "stdafx.h"
#include<iostream>
#include"DoubleList.h"

using namespace std;

int main()
{
    DoubleList<int> list;
    return 0;
}