One reason you may want to constrain access to constructors is if you want to control creation of the object. An example of this would be the Singleton pattern. If you search google for it, you will find lots of descriptions, along with heated debate about it's usefulness!
I realised that I didn't answer your question directly. A protected constructor is only available to the class and it's subclasses. So, this could be used in a situation where you want the subclass to have control over initialisation, while restricting instantiation of the base type.
[ February 28, 2005: Message edited by: Horatio Westock ]
Constructors, static initializers, and instance initializers are not members and therefore are not inherited.
I stand corrected. Apologies, I was thinking (incorrectly) of super class access
posted 15 years ago
Hi westok, I have understood how we can have control over initialization of a class,that really sounds good . But still I think I need to look for some exapmles that demonstrate its usefullness,so that I could use it in that way. see If you or somebody can provide it.
An abstract class might declare a protected constructor. This makes it more clear that the abstract class cannot be instantiated, but any subclasses can still call the constructor.
Horatio said, "A protected constructor is only available to the class and it's subclasses." This is not completely true. The protected access modifier also grants access to other classes in the same package, even if they are not subclasses of said class.