Singleton Pattern

Singleton Pattern

Postby elektor » Tue Sep 11, 2012 8:07 am

Hi Daniel,



I understand that the Singleto pattern is used to create only one instance of an object.



In the Greenbook\Patterns\Singleton code. I can create two instances of the AnyOldThing class



Code: Select all

AnyOldThing* pp = Singleton<AnyOldThing>::instance();

cout << pp -> coeff() << endl;

AnyOldThing *hp = Singleton<AnyOldThing>::instance();

cout << hp -> coeff() << endl;





Isn't that countering the meaning of the singleton?



Regards

Neville
elektor
 
Posts: 4
Joined: Thu Sep 06, 2012 8:39 pm
Location: Berlin, Germany

Return to Design Patterns

Who is online

Users browsing this forum: No registered users and 1 guest

cron