
14 Feb
2005
14 Feb
'05
3:12 p.m.
Sérgio Vale e Pace wrote:
On Mon, 14 Feb 2005 16:00:08 +0200, Peter Dimov <pdimov@mmltd.net> wrote:
This is not a problem. The designer of Example does permit such use:
Example a; Example b;
Sorry for the ignorance, but then what´s the point of using the singleton if Example is not suposed to be a singleton?
A class that supports an arbitrary number of instances also supports a single instance. It's not a programming error to use one instance of Example as a "singleton" to solve the initialization order problem (the only legitimate use of the "singleton pattern", in my opinion). The reverse, of course, is not true. If a class only supports a single instance the programmer shouldn't be allowed to create multiple instances.