64,643
社区成员
发帖
与我相关
我的任务
分享
template<long sz>
class
ZeroStack
{
void DoIt(){};
}
struct A
{
static ZeroStack<-1> zs;
};
A::zs.DoIt(); // error LNK2001: 无法解析的外部符号
A().zs.DoIt(); // error LNK2001: 无法解析的外部符号
template<long sz>
class ZeroStack
{
public:
void DoIt() {};
};
struct A
{
static ZeroStack<-1> zs;
};
ZeroStack<-1> A::zs;
int main()
{
A::zs.DoIt();
A().zs.DoIt();
return 0;
}
A::zs.DoIt();
A().zs.DoIt();
这两句应该写在某个函数中,还有void DoIt(){}这个函数应该使用public访问限定,class最后哎有分号
ZeroStack<-1> A::zs;