在模版类中使用静态std::set或者std::map出现链接错误

shootingstars shootingstars 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

class ClassA
{
};

template < typename T > class TemplateTest
{
public:
static bool getStatus(int i){
return mapint.find(i)==mapint.end()?true:false;
}
static std::set<int> mapint;
};

void TestT()
{
bool b = TemplateTest<ClassA>::getStatus(0);
}

使用vs编译出现如下链接错误
error LNK2001: 无法解析的外部符号 "public: static class std::set<int,struct std::less<int>,class std::allocator<int> > TemplateTest<class ClassA>::mapint"

为啥呢?请假各位大侠。
...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
shootingstars
C++ 语言 65,214 成员 250,514 内容