我有以下代码:C++类的静态成员初始化
class employee {
public:
static int last_id;
...
};
int main() {
employee::last_id=0;
}
当我尝试运行它,它提供了以下错误:
Undefined symbols for architecture x86_64:
"employee::last_id", referenced from:
_main in chap7-F3IpS1.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
[Finished in 0.3s with exit code 1]
应该用google搜索这个。我记得遇到这个错误。当我GOOGLE了它,前10个左右的结果指向堆栈溢出。难怪我可以解决这个问题,而不会发布*另一个副本。* – 2013-12-23 19:44:18