C++ の初期化(2)
前回の続き。
普通のクラス変数定義
MyClass m;
コンストラクタによる初期化付き定義
MyClass m(arg1, arg2);
この構文をプリミティブ型(int, double, ...)に適応すると普通の代入と同じになるらしい。
int m(10); // <=> int m = 10;
もちろん、
int m(10, 20);
はできない。gcc では次のエラーが出る。
error: initializer expression list treated as compound expression
warning: left-hand operand of comma has no effect