我有以下代碼: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