我最近在制作模板链表,但是我确实遇到了问题
#ifndef _T_NODE_
#define _T_NODE_
using namespace std;
template<typename T>
class TNode{
public:
TNode();
TNode(T a);
~TNode();
private:
T template_;
TNode<T> *link_;
};
#endif
我的实施是:
template<typename T>
TNode<T>::TNode(){
link_ = NULL;
template_ = T();
}
template<typename T>
TNode<T>::TNode(T a){
template_=a;
link_ = NULL;
}
template<typename T>
TNode<T>::~TNode(){
delete link_;
}
在另一个班级中,我试图在一个函数中引用它:
TNode<Bike> * actPtr;
actPtr = new TNode<Bike>(a);
我收到以下错误:
error LNK2019: unresolved external symbol "public: __thiscall TNode<class Bike>::TNode<class Bike>(class Bike)" referenced in function "public: void __thiscall