主题:MFC中模板使用的问题
本来想将二叉树的类模板移植到MFC上,然后在编写一些显示代码,但一开始就遇到最基本的困难
下面是截取一些最简单的片段
//BinTree.h
template <class T>
class BinTree
{
public:
BinTree<T>();
virtual ~BinTree<T>();
};
//BinTree.cpp
template <class T>
BinTree<T>::BinTree()
{
}
template <class T>
BinTree<T>::~BinTree()
{
}
void CBinaryTreeView::OnDraw(CDC* pDC)
{//...
BinTree<char> tree;
}
编译不能通过.
编译结果,恳请大虾赐教.
BinaryTreeView.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall BinTree<char>::~BinTree<char>(void)" (??1?$BinTree@D@@UAE@XZ)
BinaryTreeView.obj : error LNK2001: unresolved external symbol "public: __thiscall BinTree<char>::BinTree<char>(void)" (??0?$BinTree@D@@QAE@XZ)
下面是截取一些最简单的片段
//BinTree.h
template <class T>
class BinTree
{
public:
BinTree<T>();
virtual ~BinTree<T>();
};
//BinTree.cpp
template <class T>
BinTree<T>::BinTree()
{
}
template <class T>
BinTree<T>::~BinTree()
{
}
void CBinaryTreeView::OnDraw(CDC* pDC)
{//...
BinTree<char> tree;
}
编译不能通过.
编译结果,恳请大虾赐教.
BinaryTreeView.obj : error LNK2001: unresolved external symbol "public: virtual __thiscall BinTree<char>::~BinTree<char>(void)" (??1?$BinTree@D@@UAE@XZ)
BinaryTreeView.obj : error LNK2001: unresolved external symbol "public: __thiscall BinTree<char>::BinTree<char>(void)" (??0?$BinTree@D@@QAE@XZ)