仮想継承を使用して菱形継承問題を解決できることはわかっています。
例えば:
class Animal // base class
{
int weight;
public:
int getWeight() { return weight;};
};
class Tiger : public Animal { /* ... */ };
class Lion : public Animal { /* ... */ };
class Liger : public Tiger, public Lion { /* ... */ };
int main()
{
Liger lg ;
/*COMPILE ERROR, the code below will not get past
any C++ compiler */
int weight = lg.getWeight();
}
このコードをコンパイルすると、あいまいなエラーが発生します。ここで私の質問は、コンパイラがこのあいまいさの問題(菱形継承問題)を内部でどのように検出するかです。