OK, I am bit confused now.
Could you give the real names of your classes & the function, I might understand better if I can see the real world situation. Can show the inheritance like this:
1 2 3 4 5 6
|
class HI {};
class RH: public HI {};
class JI: public HI {};
class RJ: public RH, public JI {};
|
In my case I want to satisfy the interface JI (deriving from HI) "saying" "provide the function functionA" by inheriting from another class RH, which implements it. Shouldn't that be possible? |
It has just occurred to me why this might not work. The compiler keeps track of classes with a PTABLE, and virtual functions with a thing called a VTABLE. As I understand it, each derived class maintains a list of pointers to it's base class - this is the PTABLE. Something similar happens for the virtual functions - this is the VTABLE. This is how the compiler can call virtual functions that are defined higher up in the inheritance tree, by following a chain of pointers up the inheritance tree.
So for your situation, can you define functionA in JI rather than RH?
For this error:
main.cpp(6) : error C2385: ambiguous access of 'functionA'
1> could be the 'functionA' in base 'RH'
1> or could be the 'functionA' in base 'HI'
1>main.cpp(6) : error C3861: 'functionA': identifier not found |
This is definitely the "Diamond problem" as explained by wiki.
I guess you need to look at why you are doing multiple inheritance. Normally you would do this if you wanted to inherit some of the functionality from class RH say, and different functionality from the other class JI. By having a virtual function in the base class HI, you introduce ambiguity, unless you can use the the scope operator to explicitly call the correct class function. Or use virtual inheritance as per the wiki article.