我已经定义了一个单身如下:
struct Conditions {
bool bMonolithic;
bool bKeepVersion;
bool bToc;
static Conditions& initialize() {
if (instance == nullptr)
instance = new Conditions;
return *instance;
}
private:
Conditions():bMonolithic(false), bKeepVersion(false), bToc(false) {}
static Conditions* instance;
};
当我尝试使用它时,我调用了initialize()函数:
Conditions& kcondition = Conditions::initialize();
然而,编译器给了我这个错误:
error LNK2001: unresolved external symbol "private: static struct Conditions * Conditions::instance" (?instance@Conditions@@0PEAU1@EA)
使用单身人士的正确方法是什么?