我试图创建一个双链接列表和相应的节点类,并尝试将头和尾的数据类型添加到我的IntDLList类有一个问题 . 我不太确定我错过了什么,但是发生了一个错误,声明头部和尾部都没有声明,而且我的Node类没有采用类型 . 任何帮助表示赞赏!

编辑:这似乎不是一个重复的问题,我看了其他答案,并尝试解决无效使用不完整类型没有解决与我的名称类型错误相同的问题 .

IntDLList

using namespace std;

template <class T>
class IntDLList {
public:
       IntDLList() {
           head=tail=0; // error: 'head' was not declared in this scope (& same for tail)
       }
       ~IntDLList();
       int isEmpty() {
           return head==0; // error: 'head' was not declared in this scope
       }
       void addToDLLHead(const T&);
       void addToDLLTail(const T&);
       T deleteFromDLLHead();
       T deleteFromDLLTail();
       void deleteDLLNode(const T&);
       bool isInList(const T&) const;
       void showList();
private:
       IntDLLNode<T> *head, *tail; //error: IntDLLNode does not name a type
};

IntDLLNode

using namespace std;

template<class T>
class IntDLLNode {
    friend class IntDLList;
    public:
        IntDLLNode() {next = prev = 0;}
        IntDLLNode(const T& el, IntDLLNode *n = 0, IntDLLNode *p = 0) {
            info = el;
            next = n;
            prev = p;

        }
    protected:
         T info; 
         IntDLLNode<T> *next,*prev;
    private:

};