I've a current class that declares an online method and defines a default implementation. Now I wish to overload that method having a differend parameter as well as provide a default implementation. Additionaly I wish to enforce the constraint, that when the first method got overridden with a subclass then your second (overloaded) virtual method should be overridden too.

Is even possible inside C++? If that's the case, is it feasible 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
    }
}

Let me identify classes of type Derived and enforce these to implement their verison of method(ParamB b).

No, you cannot specify complex constraints which teams of member functions should be overridden. The only real constraints affect individual functions pure virtual (=0) to mandate overriding, and (in C++11) final to avoid overriding.

The very best you should do is make both functions pure virtual, forcing the derived class to override both. This a minimum of forces the writer from the derived class to consider what needs overriding you can't really override one and end up forgetting another one.

You are able to still give a default implementation, to ensure that derived classes that don't wish to override either function just have very short overrides that call the default versions.

I believe C++ doesn't provide any way to identify such missing override inside a child.

@larsmans: Making both techniques pure virtuals results in missing the default implementation.

@js_: would you elaborate a little in your actual problem? What you are looking for appears to become conceptually not too obvious in my experience.

What about developing a Parent class that Base will inherit? These 2 functions is going to be pure virtual within the Parent class. The derived classes will inherit Parent (and never Base), and will need to implement both functions.

Should you all you want use may be the parent class, then no. It isn't possible neither at compile time, nor like a runtime check.

Obviously, you can introduce some macros (like say OVERRIDE_Techniques... I am sure the thing is what I am speaking about), but nothing can avoid the customers from disregarding them and override just one of stated techniques.

Plus such macros can make the code pretty ugly.