I have written code to understand the functionality of Singletom Class, by defintion -- singleton is one instance of a class and user of singleton doesn't have possibility to create another one. However, in my code I am able to create two instances of a Class. I would appreciate, if you can help me understand the basic concept through my code. Thank you very much..
class Rectangle
{
private:
int width, height;
static Rectangle* rectangle;
static bool instance_flag;
Rectangle(){}
~Rectangle(){}
public:
static Rectangle* getInstance();
int rectArea(void);
};
PLEASE USE CODE TAGS (the <> formatting button) when posting code.
It makes it easier to read your code and also easier to respond to your post. http://www.cplusplus.com/articles/jEywvCM9/