我有一個帶有字符串和類指針的映射。 我來自JAVA,所以請指導我。帶類指針的C++映射在編譯時出錯
class Client {
public:
static map<string, Client*> CLIENTS;
Client(string dir);
static Client* get_client(string name);
virtual ~Client();
};
我get_client方法是
Client* Client::get_client(string name) {
map<string, Client*>::iterator it = CLIENTS.find(name);
}
給我下面
Undefined symbols for architecture x86_64:
"Client::CLIENTS", referenced from:
Client::get_client(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)in client.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
如果你的'get_client'正文與你發佈的完全一樣,那就沒有意義了 – borisbn 2013-03-16 08:22:59
@borisbn我在試圖定位問題時刪除了很多代碼 – Kathick 2013-03-16 09:06:34