循環を形成する2つのクラスが必要です。どちらにも独自のメンバーがありますが、他のクラスのコピーとともに、この例を考えてみましょう。
class lower;
class upper{
int uA;
lower L;
upper(){
uA=0;
//how to initialize lower here using lower's constructor
}
};
class lower{
int lA;
upper U;
lower(){
lA=0;
//how to initialize upper here using upper's constructor
}
};
今度upper L
は main(); に上位オブジェクトが必要です。そして、それのすべての変数をゼロで初期化する必要があります(デフォルトのコンストラクターの場合)が、これらのコンストラクターの循環を処理する方法がわからないため、lower L
アッパー内で 初期化されます