I have used singleton calss following the example:
singleton class
But i get the error as \"Unresolved external symbols\"
this is th
In your definition file, you need the definition of instance:
singleton* singleton::instance = NULL;
You should separate your definition from your declaration if you want to use the singleton in multiple translation units.
Also, the way it's usually done, is not having an initialize method:
static singleton* getInstance()
{
if(instance==NULL)
instance = new singleton();
return instance;
}
There are lots of discussions on SO whether singletons are good or bad, with the general consensus that they should be avoided. You should also check them out.