zero initialization
De cppreference.com
![]() | This page has been machine-translated from the English version of the wiki using Google Translate. The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Définit la valeur initiale d'un objet à zéro
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.
Sommaire |
[modifier]Syntaxe
static Tobject; | (1) | ||||||||
int() ; | (2) | ||||||||
char array[ n] = ""; | (3) | ||||||||
[modifier]Explication
Zéro initialisation est effectuée dans les conditions suivantes:
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)
Pour chaque variable nommée avec la durée de stockage statique ou locale de thread, avant toute autre initialisation .
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)
Dans le cadre de la séquence la valeur d'initialisation pour non-classe des types et des membres de valeur initialisée types de classes qui n'ont pas de constructeurs .
Original:
As part of la valeur d'initialisation 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)
Quand un tableau de caractères initialisé avec une chaîne littérale qui est trop court, le reste du tableau est initialisé à zéro .
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.
Les effets de l'initialisation à zéro sont les suivants:
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.
- Si
T
est un type scalaire, la valeur initiale de l'objet est la implicitement convertie intégrale nulle constante àT
.Original:IfT
is a scalar type, the object's initial value is the integral constant zero implicitement convertie toT
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Si
T
est un type de classe non syndiqués, toutes les classes de base et non les données membres statiques sont initialisé à zéro, et tout le rembourrage est initialisé à zéro bits. Les constructeurs, le cas échéant, sont ignorés .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.
- Si
T
est un type d'union, le premier non-membre statique de données nommé est initialisé à zéro et tout le rembourrage est initialisé à zéro bits .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.
- Si
T
est de type tableau, chaque élément est initialisé à zéroOriginal: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.
- Si
T
est le type de référence, on ne fait rien .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.
[modifier]Notes
Les variables statiques et local des threads sont d'abord initialisé à zéro, puis de nouveau initialisé comme indiqué dans le programme, par exemple, une fonction statique local est d'abord initialisé à zéro au démarrage du programme, puis son constructeur est appelé lorsque la fonction est d'abord entré. Si la déclaration d'une classe statique non n'a pas d'initialisation, puis d'initialisation par défaut ne fait rien, laissant le résultat de la première initialisation non modifié zéro .
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.
Un pointeur est initialisé à zéro la valeur de pointeur null en son genre, même si la valeur du pointeur NULL n'est pas intégrale nulle .
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.
[modifier]Exemple
#include <string> double f[3];// zero-initialized to three 0.0'sint* p;// zero-initialized to null pointer valuestd::string s;// zero-initialized to indeterminate value// then default-initialized to ""int main(int argc, char* argv[]){staticint n = argc;// zero-initialized to 0// then copy-initialized to argc delete p;// safe to delete a null pointer}