Force subclasses to implement a certain constructor prototype in C++

Viewed 1624

Suppose I have an abstract class A. Is it possible for A to force any classes inheriting from it to implement a certain constructor prototype?

e.g.:

class A {
public:
    // purely virtual function
    virtual void func() = 0;
    // what i would like to be able to do
    virtual A(Obj) = 0;
};

While the purely virtual function func above is legal, the constructor A(Obj) cannot be virtual. I would like if instances of a class B inheriting from A will remain abstract (or some uninstantiable or erroneous equivalent) until B overrides the constructor A(Obj).

In other words, I want to force any subclass of A to implement a constructor that takes an Obj as an argument. Is this possible?

1 Answers
Related