Why would anyone declare a constructor protected? I know that constructors are declared private for the purpose of not allowing their creation on stack.
See Question&Answers more detail:osWhy would anyone declare a constructor protected? I know that constructors are declared private for the purpose of not allowing their creation on stack.
See Question&Answers more detail:osWhen a class is (intended as) an abstract class, a protected constructor is exactly right. In that situation you don't want objects to be instantiated from the class but only use it to inherit from.
There are other uses cases, like when a certain set of construction parameters should be limited to derived classes.