今天写Template的时候发现LNK2001错误,说找不到Template类的构造函数和析构函数。找MSDN发现:
The definition of member template is outside the class. Visual C++ has
a limitation in which member templates must be fully defined within the
enclosing class. See KB article Q239436 for more information about
LNK2001 and member templates.
只好将实现放入头文件了。
如果Template类需要继承:可以这样写:
template <class T> class ChildClass : public ParentClass<T>
{
......
};