Avoid multiple inheritance induced ambiguity by using scope resolution
问题 Here is an example of multiple inheritance. I used the scope resolution operator to resolve the ambiguity instead of a virtual class. struct A { int i; }; struct B : A {}; struct C : A {}; struct D: B, C { void f() { B::i = 10; } void g() { std::cout << B::i <<std::endl; } }; int main() { D d1; d1.f(); d1.g(); return 0; } Is B::i well-formed? 回答1: Is B::i well-formed? Yes, it is. The most pertinent reference is [class.qual]/1: If the nested-name-specifier of a qualified-id nominates a class,