class Singleton
{
private:
static Singleton* _SInstance;
public:
Singleton(){}
staticvoid _GetInstance()
{
_SInstance = new Singleton();
}
};
//Singleton * Singleton::_SInstance=NULL;
int main()
{
Singleton::_GetInstance();
return 0;
}
In the above program when I compile I am getting linking
Error: undefined reference to 'Singleton::_SInstance'
But when I Initializing NULL to the _SInstance in global scope.
Its works fine.
So my question is why the linking error? When it is not Initialized