Originally posted by Shikhar Madhok:
Keeping a constructor private would mean that no code can create an instance of that class using the new operator i.e.
Will not be allowed.
One use of this is in the Singleton pattern wherein it is required to create only one instance of the class. To read more about the singleton pattern check this link
HTH
Shikhar[/qb]
No.
Only code within the class that has the private constructor can create and instance of the class using the new keyword.
Code from other classes cannot invoke the new keyword on an instance of the class that has the private constructor.
You could create a static instance within your class and have a static factory method that returns a reference to this singleton object like so:
Best regards
[ July 13, 2008: Message edited by: Keith Nagle ]
[ July 13, 2008: Message edited by: Keith Nagle ]