This is a true story of evolving code. We began with many classes based on this structure:
class Base
{
public:
virtual void doSomething() {}
};
class Derived : public Base
{
public:
void doSomething() override
{
Base::doSomething(); // Do the basics
// Do other derived things
}
};
At one point, we needed a class in between Base and Derived:
class Base;
class Between : public Base;
class Derived : public Between;
To keep the structure, Between::doSomething()
first calls Base.
However now Derived::doSomething()
must be changed to call Between::doSomething()
...
And this goes for all methods of Derived, requiring search & replace to many many calls.
A best solution would be to have some this->std::direct_parent mechanism to avoid all the replacements and to allow easy managing of class topology.
Of course, this should compile only when there's a single immediate parent.
Is there any way to accomplish this? If not, could this be a feature request for the C++ committee?