First of all apologies if this is a newbie question but I'm beginner at this. My question is a variant of the diamond problem I believe.
Imagine I have the following classes:
class A{ public: virtual foo();};
class B{ public: foo();};
class C{ public: foo();};
class D: public A, public B, public C{
public: foo();
};
My question is is it possible to call foo() from class D and have the virtual function run across A, B, C and D. I have tried this but the d::foo() function overrides all the other foo() functions.
Or is it only possible if you make a 1:2 inheritance scheme?
class A{ public: virtual foo();};
class B: public A { public: foo();};
class C: public B { public: foo();};
class D: public C { public: foo();};
The reason I ask is because I would like to be able to construct A, B and C in different classes without having to construct each time also A or B or C but retain the possibility of running the virtual function without having to call for each case A::foo(), B::foo(), C::foo().