We all knew that, the below class will give us only one instance of the class.
class Singleton
{
private:
static Singleton* singleton;
private:
Singleton();
public:
static Singleton* getIntsance();
};
Just think that is there any other way to do the same. Yes, we have onother solution for it. See below
class Singleton
{
private:
static Singleton* singleton;
private:
~Singleton();
public:
static Singleton* getIntsance();
};
Destructor is in private scope now.
Thursday, April 8, 2010
Subscribe to:
Post Comments (Atom)
1 comment:
I guess copy constructor has to be declared private as well.
Post a Comment