| Author |
Constructors in a class
|
Ravi Hyd
Greenhorn
Joined: Jun 27, 2005
Posts: 4
|
|
|
I want to know whether we can create a Private default constructor in a class. Can anybody explain what is Singleton class?
|
 |
Manuel Moons
Ranch Hand
Joined: Mar 05, 2002
Posts: 229
|
|
Yes, it is possible to create a private default Constructor. If all constructors are private you cannot create an instance from outside that class. If you create a public static method that always returns the same instance of that class you have used the singleton pattern. Look at the example:
|
 |
 |
|
|
subject: Constructors in a class
|
|
|