I try to create a multi-threaded singleton pattern class.
Header:
class HL{
public:
static HL* getInstance();
.........
private:
static HL* instance;
static boost::once_flag flag;
HL();
static void initOnce();
}
CPP:
HL* HL::instance = NULL;
HL* HL::getInstance(){
if(instance == NULL){
boost::call_once(flag, initOnce);
}
return instance;
}
void HL::initOnce(){
instance = new HL();
}
I get this error:
error LNK2001: unresolved external symbol "private: static long Nsp::HL::flag" (?flag@HL@Nsp@@0JA)
What's wrong?