I have an existing class that declares a virtual method and defines a default implementation. Now I want to overload that method with a differend parameter and also give a default implementation. Additionaly I want to enforce the constraint, that if the first method got overridden by a subclass then the second (overloaded) virtual method must be overridden too.
Is this even possible inside C++? If so, is it possible at compile time?
Example code:
class ParamA {};
class ParamB {};
class Base
{
public:
virtual void method(ParamA a)
{
// default behavior
}
virtual void method(ParamB b)
{
// default behavior
}
}
class Derived : public Base
{
public:
virutal void method(ParamA)
{
// special behavior
}
}
My goal is to detect classes of type Derived
and enforce them to implement their verison of method(ParamB b)
.