I think when we have to create a singleton class, we can use private constructor. Objects of such classes can be constructed using static functions that can be accessed using class name and scope resolution operators. This is useful because user can create only one object of that class, which is sometimes required.
other case might be using static functions, but return a new object each time. We can also keep a limit on the no. of objects that can be created for a class. Sanju :) On Mon, Sep 5, 2011 at 9:06 AM, Neha Singh <[email protected]>wrote: > When do u hv a private constructor for a class ??? > How to create an object of such a class ?? > What's its utility ?? > > > Anyone plz explain asap?? > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
