I have a class which is a Singleton class. In the CPP file I have:
static std::unique_ptr<CStage> s;
MSOCPPAPITYPE_(ICStage&) GetInstance()
{
try
{
s = std::make_unique<CStage>();
}
catch (...)
{
}
return *s;
}
Within another file I call GetInstance().SetMValue(true);
which is a function that sets a member variable of the class to true
. The default value of the member variable is false
. Then I call GetInstance().GetMValue();
which returns the value of the member variable. Instead of returning true
I get a false
return value. This causes me to believe that I am not properly using the singleton. How do I properly use my class as a singleton?