//这是类模板的声明
template
class LIST
{
public:
struct NODE
{
T element;
NODE next;
NODE *prv;
};
private:
NODE *start;
NODE *end;
int num;
LIST(const LIST &l) {}
LIST & operator=(const LIST &l) {}
public:
LIST();
NODE find(const T &ele);
bool insert(const T &ele);
bool insert(const T &ele,const NODE pos = end);
bool isempty()const;
void empty_LIST();
T get_element(const NODE pos = end);
~LIST();
};
//就是这个函数出错了,不知道为什么
template
LIST::NODE* LIST::find(const T &ele)//在VS2017中编译,编译直接停止
{
LIST::NODE *curr = start;
while (curr != end)
{
if (ele == curr->element)
{
return curr;
}
curr = curr->next;
}
curr = NULL;
return curr;
}
https://blog.csdn.net/qq_31407743/article/details/52195773
里面的结构也应该写成模板,它不会因为类是个用的类型T就自动称为类型T了