作曲用に次のコードがあります。エラーが発生し、
#include <iostream>
using namespace std;
class X
{
private:
int iX;
public:
X(int i=0) : iX(i) { cout <<"Constructing X.."<<endl; }
~X() { cout <<"Destructing X.."<<endl; }
int getIX() { return iX; }
};
class Y
{
private:
X x(3);
int jY;
public:
Y(int j = 0) : jY(j) { cout <<"Constructing Y.."<<endl; }
~Y() { cout <<"Destructing Y.."<<endl; }
void callGetX() { cout <<"iX is "<<(x.getIX())<<endl; }
};
int main()
{
Y yObj(1);
yObj.callGetX();
}
エラー:メンバー関数でvoid Y :: callGetX()'x'が宣言されていません(最初にこの関数を使用してください)
私が見逃したものはありますか?このシナリオのコンストラクター呼び出しメカニズムを教えてもらえますか?