BigMan wrote:
I need to design a class that meets the following requirements:
-the class may not have more that one instance;
-the instance needs arguments for initialization;
-accessing the instance must not require any arguments;
How do you plan to provide the arguments? It's of course easy
to provide a static setArguments(...) method for your Singleton
class which you must call before calling the canonical
static Singleton& getInstance().
The private ctor/public static getInstance pattern guarantees
your first and third conditions, but there's no way to enforce
at compile time that setArguments is called. At best you can
throw from getInstance().
HTH,
Michiel Salters