求教:关于在类中建立静态模板的问题
class Math
{
public:
template <class T>
static T sqrt(T n);
};
template <class T>
T Math::sqrt(T n)
{
return n;
}
void main()
{
float tmp = Math::sqrt(1.0f);
}
编译过的,但是出现连接错误:错误
error LNK2019: 无法解析的外部符号 "public: static float __cdecl Math::sqrt<float>(float)" (??$sqrt@M@Math@@SAMM@Z),该符号在函数 _main 中被引用 zmMain.obj zmLib
能不能这样写,有人能解释一下吗?