hai every body,
how can we create an instance of a class , having the constructor with the private access specifier.........
pls can any body tell me the answer..........
Thanks in Advace ...........
Regads
mallik
Printable View
hai every body,
how can we create an instance of a class , having the constructor with the private access specifier.........
pls can any body tell me the answer..........
Thanks in Advace ...........
Regads
mallik
The private constructor can be called from a static member of that class. Like:
class ClassA{ ClassA(); public: static void* create(){return new ClassA();}};
Another reason for a private constructor is to hide a default constructor and to force the class user to construct it using a constructor with arguments.