【发布时间】:2014-10-16 22:00:30
【问题描述】:
我有一个标题:
class a
{
public:
a();
static int Zero();
void SimpleEx();
}
及其cpp文件:
a() { }
static int a::Zero() {return 0;}
void SimpleEx() { cout << a::Zero(); }
编译时出现错误:
错误 1 错误 LNK2019:未解析的外部符号“public: static class a __cdecl a::Zero(void)” (?Zero@a@@SA?AV1@XZ) 在函数“public: class a __thiscall a:”中引用:SimpleEx(void)" (?SimpleEx@a@@QAE?AV1@XZ)
如何解决这个问题?
【问题讨论】:
-
尽量不要使用static关键字
标签: c++11 static-methods