C++で仮想継承のコンストラクタ呼び出しの順序は何ですか?仮想継承のコンストラクタ呼び出しの順序は?
複数の継承の次の2つのケースについては、
(I)、仮想継承なしの次のコード。
class a
{
public:
a()
{
cout<<"\t a";
}
};
class b: public a
{
public:
b()
{
cout<<"\t b";
}
};
class c: public b
{
public:
c()
{
cout<<"\t c";
}
};
class d: public c
{
public:
d()
{
cout<<"\t d";
}
};
class e: public c, public d
{
public:
e()
{
cout<<"\t e";
}
};
class f: public b, public e
{
public:
f()
{
cout<<"\t f";
}
};
int main()
{
f aaa;
return 0;
}
出力は次のようになります。
a b a b c a b c d e f
クラスEの仮想継承と(II):
class a
{
public:
a()
{
cout<<"\t a";
}
};
class b: public a
{
public:
b()
{
cout<<"\t b";
}
};
class c: public b
{
public:
c()
{
cout<<"\t c";
}
};
class d: public c
{
public:
d()
{
cout<<"\t d";
}
};
class e: public c, public d
{
public:
e()
{
cout<<"\t e";
}
};
class f: public b, public virtual e
{
public:
f()
{
cout<<"\t f";
}
};
int main()
{
f aaa;
return 0;
}
出力は次のとおりです。
a b c a b c d e a b f
誰かがどのように説明することができます両方の場合に出力が得られますか? 仮想継承はどのようにオブジェクトの構築に影響しますか?