Espaces de noms
Variantes
Actions

zero initialization

De cppreference.com
< cpp‎ | language

 
 
Langage C++
Sujets généraux
Contrôle de flux
Instructions conditionnelles
Instructions d'itération
Instructions de saut
Fonctions
déclaration de fonction
expression lambda
fonction générique
spécificateur inline
spécification d'exception (obsolète)
spécificateur noexcept (C++11)
Exceptions
Espaces de noms
Types
spécificateur decltype (C++11)
Qualificatifs
qualificatifs const et volatile
qualificatifs de stockage
qualificatif constexpr (C++11)
qualificatif auto (C++11)
qualificatif alignas (C++11)
Initialisation
Littéraux
Expressions
opérateurs alternatifs
Utilitaires
Types
déclaration typedef
déclaration d'alias de type (C++11)
attributs (C++11)
Jette
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversions implicites
conversion const_cast
conversion static_cast
conversion dynamic_cast
conversion reinterpret_cast
conversions style C et style fonction
Allocation de mémoire
Classes
Qualificatifs spécifiques aux membres de classe
Fonctions membres spéciales
Modèles
classes génériques
fonctions génériques
spécialisation de modèles
paquets de paramètres (C++11)
Divers
Assembleur
 
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.

Sommaire

[modifier]Syntaxe

staticTobject; (1)
int(); (2)
chararray[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.
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.
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.
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.
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.
  • Si T est un type scalaire, la valeur initiale de l'objet est la implicitement convertie intégrale nulle constante à T .
    Original:
    If T is a scalar type, the object's initial value is the integral constant zero implicitement convertie to T.
    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:
    If T 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:
    If T 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éro
    Original:
    If T is array type, each element 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.
  • Si T est le type de référence, on ne fait rien .
    Original:
    If T 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.
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.

[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}


[modifier]Voir aussi

close