zero initialization
提供: cppreference.com
![]() |
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
ゼロにオブジェクトの初期値を設定します
Original:
Sets the initial value of an object to zero
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] 構文
static T object ;
|
(1) | ||||||||
int () ;
|
(2) | ||||||||
char array [ n ] = "";
|
(3) | ||||||||
[編集] 説明
ゼロ初期化は、次のような状況で行われます
Original:
Zero initialization is performed in the following situations:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
1)
すべての他の任意の初期化前に、静的またはスレッドローカル記憶域期間を持つ変数の名前.
Original:
For every named variable with static or thread-local storage duration, before any other initialization.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
2)
非クラスタイプのためとはコンストラクタを持たない値に初期化されたクラス型のメンバに対して値初期化シーケンスの一部として.
Original:
As part of 値初期化 sequence for non-class types and for members of value-initialized class types that have no constructors.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
3)
文字配列は短すぎる文字列リテラルで初期化されると、配列の残りはゼロで初期化されている.
Original:
When a character array is initialized with a string literal that is too short, the remainder of the array is zero-initialized.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
ゼロ初期化の効果は、次のとおりです
Original:
The effects of zero initialization are:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
-
T
がスカラー型である場合、オブジェクトの初期値は暗黙的に変換されますに整数定数ゼロのT
です.Original:The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
T
は非組合クラス型である場合は、すべての基本クラスと非静的データメンバは、ゼロで初期化され、すべてのパディングがゼロ·ビットに初期化されます。コンストラクタは、もしあれば、無視される.Original:IfT
is an non-union class type, all base classes and non-static data members are zero-initialized, and all padding is initialized to zero bits. The constructors, if any, are ignored.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
T
が共用体型の場合、最初の非静的データメンバの名前は、ゼロで初期化され、すべてのパディングがゼロ·ビットに初期化され.Original:IfT
is a union type, the first non-static named data member is zero-initialized and all padding is initialized to zero bits.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
T
が配列型である場合、各要素は、ゼロで初期化されていますOriginal:IfT
is array type, each element is zero-initializedThe text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
-
T
が参照型の場合、何も行われません.Original:IfT
is reference type, nothing is done.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[編集] ノート
静的およびスレッドローカル変数は、ゼロで初期化された第一であり、プログラムで指定されているように、例えば、再度初期化関数ローカルスタティックは最初のプログラムの起動時にゼロに初期化され、関数が初めて呼び出されたときに、そのコンストラクタが呼び出されます。非静的クラスの宣言は初期化子がない場合は、デフォルトの初期化は無修正でゼロ初期化以前の結果を残して、何もしません.
Original:
The static and thread-local variables are first zero-initialized and then initialized again as specified in the program, e.g. a function-local static is first zero-initialized at program startup, and then its constructor is called when the function is first entered. If the declaration of a non-class static has no initializer, then default initialization does nothing, leaving the result of the earlier zero-initialization unmodified.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
ゼロで初期化されたポインタがヌルポインタの値は、積分がゼロでない場合でも、その型のヌルポインタ値です.
Original:
A zero-initialized pointer is the null pointer value of its type, even if the value of the null pointer is not integral zero.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
このコードを実行します
#include <string> double f[3]; // zero-initialized to three 0.0's int* p; // zero-initialized to null pointer value std::string s; // zero-initialized to indeterminate value // then default-initialized to "" int main(int argc, char* argv[]) { static int n = argc; // zero-initialized to 0 // then copy-initialized to argc delete p; // safe to delete a null pointer }