The Wayback Machine - https://web.archive.org/web/20180305141735/http://ja.cppreference.com:80/w/cpp/language/initializer_list
名前空間
変種
操作

Initializer list

提供: cppreference.com
< cpp‎ | language

 
 
C++言語
一般的なトピック
フロー制御
条件付き実行文
繰り返し文 (ループ)
ジャンプ文
関数
関数宣言
ラムダ関数宣言
inline 指定子
例外指定(廃止予定)
noexcept 指定子(C++11)
例外
名前空間
指定子
decltype(C++11)
auto(C++11)
alignas(C++11)
記憶域期間指定子
初期化
代替表現
リテラル
ブーリアン - 整数 - 浮動小数点
文字 - 文字列 - nullptr(C++11)
ユーザ定義(C++11)
ユーティリティ
アトリビュート(C++11)
typedef 宣言
型エイリアス宣言(C++11)
キャスト
暗黙の変換 - 明示的な変換
static_cast - dynamic_cast
const_cast - reinterpret_cast
メモリ確保
クラス
クラス宣言
初期化子リスト
this ポインタ
クラス固有の関数特性
特別なメンバ関数
テンプレート
その他
 
はstd :: initializer_listと混同しないでください)​​
Original:
( Not to be confused with はstd :: initializer_list )
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
彼らは、メンバーと祖先の初期化のために責任があるコンストラクタの一部です
Original:
They are the part of a constructor which is responsible for member and ancestor initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]構文

constructor_signature:member_constructor_calls{constructor_body}

[編集]説明

初期化子リストは、オブジェクトの初期化が必要な箇所ですが、基底クラスやメンバのコンストラクタが呼び出されている場所がある.
Original:
The initializer list is the place where initialization of the object should occur, there is where the constructors for base classes and members are called.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
宣言されているようなメンバーは、彼らは初期化子リストで表示されないように、同じ順序で初期化され.
Original:
Members are initialized in the same order as they are declared, not as they appear in the initializer list.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
コンストラクタのパラメータは、メンバーの一人、intializerリスト内部のコンストラクタ呼び出しで渡されて、その識別子の曖昧さと同じ名前を持つ場合は、このパラメータを(メンバーではありません)を選択する解決されています.
Original:
If a parameter in the constructor has the same name as one of the members, the ambiguity of that identifier being passed in a constructor call inside the intializer list is resolved choosing the parameter (and not the member).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
リスト内に存在しないメンバや基本クラスは、デフォルトで構成されるでしょう
Original:
Members or base classes not present in the list will be default constructed
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[編集]

struct Class :public Base {int x;int y;   Class (int x ): Base (123), // initialize base class x ( x ), // x (member) is initialized with x (parameter) y (0)// y initialized to 0{}// empty constructor body   Class (double a ): y ( a+1), x ( y )// x will be initialized before y, this means that its value here is undefined{}// No base class constructor in list, this is the same as calling Base()   Class()try: Base (789), x (0), y (0){// no exception}catch(...){// exception occurred on initialization}};
close