c++ - 错误 'TempSLLNODE' : use of class template requires template argument list

标签 c++ templates

<分区>

#ifndef TEMPLATE_LINKED_LIST
#define TEMPLATE_LINKED_LIST


template <class T>
class TempSLLNODE
{
public:
    T info;
    TempSLLNODE *next;
    TempSLLNODE( T value, TempSLLNODE *ptr = NULL)
    {
        info = value;
        next = ptr;
    }
};

template <class T>
class TempSLL
{
public:
    TempSLL()
    {
        head = tail = 0;
    }
    ~TempSLL();
    T isEmpty()
    {
        return head == 0;
    }
    void addToHead(T);
    void addToTail(T);
    T deleteFromHead();   // delete the head and return its info;
    T deleteFromTail();   // delete the tail and return its info;
    void deleteNode(T);
    bool isInList(T) const;
private:
    TempSLLNODE *head, *tail;
};

#endif

最佳答案

TempSLLNODE 是模板,你需要使用它的类型:

更新:

TempSLLNODE *head, *tail;

到:

TempSLLNODE<T> *head, *tail;
//         ^^^

关于c++ - 错误 'TempSLLNODE' : use of class template requires template argument list,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21074379/

相关文章:

c++ - CRTP:从基调用派生类模板化方法

javascript - 为什么模板引擎和 Angular 使用双 mustache ?

c++ - cuda 文件组织的有效方式 : . cpp .h .cu .cuh .curnel 文件

python - 如何让 SWIG 在 Python 2 中返回字符串的 unicode 对象?

c++ - 内联函数的前向声明

c++ - 在 C++11 上模拟通用/模板化 lambda

c++ - 为什么要比较 Unsigned Int >= 0 a "Pointless Comparison"?

c++ - "n"键在Lua表中有什么特殊含义吗?

C++ - 对基类运算符的 undefined reference

c++ - 检查模板参数