I have used singleton calss following the example:
But i get the error as "Unresolved external symbols"
this is the code i tried out:
#include<iostream>
using namespace std;
class singleton
{
int value;
static singleton *instance;
protected:
singleton()
{
value=0;
}
public:
static void initialize()
{
if(instance==NULL)
singleton();
else
cout<<"An instance of singleton already exist...";
}
static singleton& getInstance()
{
return *instance;
}
int getValue()
{
return value;
}
};
void main()
{
singleton::initialize();
}
A little bit explanation on Singleton classes would be really great. The scenario its used. advantages and drawbacks. Alternatives to Singleton. etc