Howdy, You could make a constructor private to prevent any outside code from directly instantiating that class. Some people use this as a form of implementing a Singleton--they make a static method like getTheObject(), and it returns the one and only one instance of that class (the first time the method is invoked, the object is created and the new object is returned; after that, the one existing object is returned regardless of how often the method is called. The point is that marking the constructor private prevents anyone from ever saying "new TheObject()", so that you have complete control over instantiation of that class, and complete control over the object(s) of that type that are allowed to be used.
You could make a constructor (among many) which you do not wish exposed- but you wish to be able to call from within its own alternate constructor or within the class itself.
You could imagine a class which could use instances of itself which are created in a specific way- perhaps with only part of the data structure utilized and which should not be allowed to be created by anything other than the implementation of the class itself.
As fred says Math is a right example of the Private constructor class.
The perfect example of Singlton class (having Private constructor) I have seen is:
A Logger class. Consider a huge application and every object in a class requires to log the activities, If every Class makes an instance of the Logger class then unnecesarily the objects will get created.
So you can make a Logger class Singleton, which will be instantited once, in the whole life of a program. And will remain live for the whole life of a program.
So: What I found is that. You can make class constructor private for following reason. 1) Not to allow the user to instantiate a class. [ September 07, 2004: Message edited by: Sampras ]