There are two bases in MultiInheritance, how can I indicate which base class I want to access in MultiInheritance?
You have an ambiguity in which the base object you call in
void MultiInheritance::bar1(){ foo(); }
The way to resolve this issue is to tell the compiler where to look for foo.
void MultiInheritance::bar1(){ Derived1::foo();
This is what is achieved with
void MultiInheritance::bar1() { Derived1& d = *this;
This is described in the standard in ยง10.2.12. This is clearly defined. Like your chain
void MultiInheritance::bar1() { Derived1& d = *this; Base& b = *this;
in the same paragraph.
Unfortunately, the region resolution operator cannot force you to switch from MultiInhteritance directly to Base as
MultiInheritance::foo(){ Derived1::Base::foo();
describes a nested Base class.
To go to the foo () function owned by Base, you use permission resolution syntax in MultiInheritance, as well as in Derived1 and Derived2.
Derived1()::foo(){ Base::foo;
If this is inappropriate, the option you proposed is the remaining option.
If so, how is this implemented by the compiler to meet the needs of polymorphism? On the one hand, virtual calls must have the same virtual function table, and on the other hand, if it does, they display different answers.
Compiler implementations are different for the compiler, and as the commentator stated: using vtables for virtual functions is a detail of the implementation. And if the implementation uses the virtual function vtable, for the implementation it is necessary to consider this scenario.