2
Je tente de créer une classe de motif singleton multi-thread.Boost C++ Singleton erreur LNK2001: symbole externe non résolu "privé: statique long Nsp :: HL :: drapeau" (? Flag @ HL @ Nsp @@ 0JA)
tête:
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();
}
Je reçois cette erreur:
error LNK2001: unresolved external symbol "private: static long Nsp::HL::flag" ([email protected]@[email protected]@0JA)
Qu'est-ce qui ne va pas?
Merci! Ça marche. 'boost :: once_flag HL :: flag = BOOST_ONCE_INIT;' –