class X
{
private:
static X* obj;
X(){};
public:
static X* setObj();
static void removeObj();
};
X* X::obj = nullptr;
X* X::setObj()
{
if ( obj == nullptr )
obj = new X;
return obj;
}
void X::removeObj()
{
delete obj;
obj = nullptr;
}
Can't exactly understand what the class and the functions does, so far I had is it will create an object is none is created?