C++ – What are practical uses of a protected constructor

c++constructorprotected

Why would anyone declare a constructor protected? I know that constructors are declared private for the purpose of not allowing their creation on stack.

Best Solution

When 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.