Say I have 4 classes:
class I { public: virtual void X() = 0; };
class A : public virtual I { public: virtual void X() { } };
class B : public I { };
class C : public A, public B { };
I
, B
and C
are abstract, where as A
is not. If I simply add virtual
to the inheritance of I
for B
, then A::X()
resolves I::X()
in C
.
However, I cannot change the source of B
.
My question: Can I get A::X()
to resolve I::X
for C
without being able to change B
? I have tried declaring A
and B
to be virtual to C
to no avail. I am trying to have no redundant code (e.g. have C declare X() { A::X(); }). Any neat hacks?
Also - there are a few questions very much like this, but I couldn't find any talking about using virtual
inheritance. Please point to me one if I missed it.