我想用vc6.0编模板类(win32 console application)
//.h文件
template<class T>
class CTmp
{
public:
T m_tDate;
public:
CTmp();
virtual ~CTmp();
void Show();};
//.cpp文件
#include "stdafx.h"
#include "iostream.h"
#include "Tmp.h"template<class T>
CTmp<T>::CTmp()
{
m_tDate=185;
}
template<class T>
CTmp<T>::~CTmp()
{
}
template<class T>
void CTmp<T>::Show()
{
cout<<m_tDate<<endl;
}
//主函数
int main(int argc, char* argv[])
{
CTmp<int> tmp;
tmp.Show();
return 0;
}
连接出错
Error LNK2001: unresolved external symbol "public: virtual __thiscall CTmp<int>::~CTmp<int>(void)" (??1?$CTmp@H@@UAE@XZ)
请教问题出在哪里?拜谢!
//.h文件
template<class T>
class CTmp
{
public:
T m_tDate;
public:
CTmp();
virtual ~CTmp();
void Show();};
//.cpp文件
#include "stdafx.h"
#include "iostream.h"
#include "Tmp.h"template<class T>
CTmp<T>::CTmp()
{
m_tDate=185;
}
template<class T>
CTmp<T>::~CTmp()
{
}
template<class T>
void CTmp<T>::Show()
{
cout<<m_tDate<<endl;
}
//主函数
int main(int argc, char* argv[])
{
CTmp<int> tmp;
tmp.Show();
return 0;
}
连接出错
Error LNK2001: unresolved external symbol "public: virtual __thiscall CTmp<int>::~CTmp<int>(void)" (??1?$CTmp@H@@UAE@XZ)
请教问题出在哪里?拜谢!
#include <afxtmpl.h>
我记不清了!
感谢luofeitarget(靶子) zjg751206(play程序) 的关注
haowh(一个人走在黑黑的夜) 加15
stoneyrh() 加5
大家不介意吧