Singleton

Hi ,

class Example{
private:
void Example()
{
cout <<" constructor ";
}
public:
static Example* obj;
static Example* instantiate()
{
if(!obj)
obj = new Example();
return obj;
}

Example* oneMore()
{
return new Example();
}
};

main()
{
Example* ptr= Example::instantiate();
ptr->oneMore();
}

In the above class i want to maintain singleton behavior .By call oneMore() it will call the constructor of Example() and breaks singleton behavior. So how to over come this problem .
Delete the function oneMore()
Topic archived. No new replies allowed.