对于以下代码,我收到链接器错误。我想知道如何初始化stl map
#include <iostream>
#include <map>
#include <string>
class Test {
public:
Test() {
}
static void setSerializer(void* fnptr, std::string className) {
m_registry.insert(std::make_pair(className, fnptr));
}
static void* getSerializer(std::string className) {
return m_registry.find(className)->second;
}
private:
static std::map<std::string, void*> m_registry;
};
void fn() {
}
int main() {
Test::setSerializer(&fn,"abc");
return 0;
}