模版声明与实现分开//怎么报无法解析?
error LNK2019: 无法解析的外部符号 "public: __thiscall CTest<int>::~CTest<int>(void)" (??1?$CTest@H@@QAE@XZ),该符号在函数 _wmain 中被引用
error LNK2019: 无法解析的外部符号 "public: __thiscall CTest<int>::CTest<int>(void)" (??0?$CTest@H@@QAE@XZ),该符号在函数 _wmain 中被引用
1>c:\users\mirro187\documents\visual studio 2010\Projects\temp_nov13\Debug\temp_nov13.exe : fatal error LNK1120: 2 个无法解析的外部命令
1>
.h
template<typename T>
class CTest
{
public:
CTest(void);
~CTest(void);
void fun();
};
.cpp
#include "StdAfx.h"
#include "Test.h"
template <typename T>
CTest<T>::CTest(void)
{
}
template <typename T>
CTest<T>::~CTest(void)
{
}
template <typename T>
void CTest<T>::fun()
{
}
#include "stdafx.h"
#include "Test.h"
int _tmain(int argc, _TCHAR* argv[])
{
CTest<int> test;
return 0;
}