I have defined a singleton as below:
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;
};
When I try to use it, I call the initialize() function:
Conditions& kcondition = Conditions::initialize();
However, the compiler gives me this error:
error LNK2001: unresolved external symbol "private: static struct Conditions * Conditions::instance" (?instance@Conditions@@0PEAU1@EA)
What is the correct way to use the singleton?