Say you have the following class hierarchy:
class A
{
public:
virtual void foo() {}
}
class B
{
public:
virtual void foo() {}
}
class C: public A, public B
{
public:
virtual void foo() override { } // This overrides both
}
class D: public A, public B
{
public:
// Is there syntax so that there is a separate override for each?
// Maybe something like:
// virtual void A::foo() override {}
// virtual void B::foo() override {}
}
Is there a way to have two foo functions on class D, such that if D is passed as a reference to an A, one function in D is called, and if D is passed as a reference to a B a different function in D is called?
The use case would be if you are inheriting from two external libraries, and they just happen to have overlapping function specifiers?