zero initialization
Da cppreference.com.
![]() | Questa pagina è stata tradotta in modo automatico dalla versione in ineglese della wiki usando Google Translate. La traduzione potrebbe contenere errori e termini strani. Muovi il puntatore sopra al testo per vedere la versione originale. Puoi aiutarci a correggere gli gli errori. Per ulteriori istruzioni clicca qui. |
Imposta il valore iniziale di un oggetto a zero
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.
Indice |
[modifica]Sintassi
static Tobject; | (1) | ||||||||
int() ; | (2) | ||||||||
char array[ n] = ""; | (3) | ||||||||
[modifica]Spiegazione
Zero inizializzazione viene eseguita nei seguenti casi:
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)
Per ogni variabile di nome con la durata di archiviazione statica o thread locale, prima di ogni altra inizializzazione.
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)
Come parte della sequenza valore di inizializzazione per non di classe i tipi e per i membri del valore inizializzati tipologie di classi che non hanno costruttori.
Original:
As part of valore di inizializzazione 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)
Quando un array di caratteri viene inizializzato con una stringa che è troppo breve, il resto della matrice è zero inizializzata.
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.
Gli effetti di inizializzazione zero sono:
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.
- Se
T
è un tipo scalare, il valore iniziale dell'oggetto è il conversione implicita integrale costante zero aT
.Original:IfT
is a scalar type, the object's initial value is the integral constant zero conversione implicita toT
.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
- Se
T
è un non-union tipo di classe, tutte le classi base e non-membri dati statici sono inizializzati a zero, e tutte le imbottiture viene inizializzato a zero bit. I costruttori, se del caso, vengono ignorati.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.
- Se
T
è un tipo di unione, il primo membro non statico di nome dati sono inizializzati a zero e tutte le imbottiture viene inizializzato a zero bit.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.
- Se
T
è di tipo array, ogni elemento è zero-inizializzatoOriginal: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.
- Se è
T
tipo di riferimento, non si fa nulla.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.
[modifica]Note
Le variabili statiche e locale del thread sono di prima inizializzati a zero e quindi inizializzato di nuovo come specificato nel programma, ad esempio una funzione locale statica è il primo zero inizializzata all'avvio del programma, e poi il suo costruttore viene chiamato quando la funzione viene inizialmente inserito. Se la dichiarazione di una non-classe statica non ha inizializzatore, quindi inizializzazione di default non fa nulla, lasciando il risultato della precedente zero inizializzazione non modificato.
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 puntatore è inizializzato a zero il valore di puntatore nullo del suo tipo, anche se il valore del puntatore nullo non è zero integrante.
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.
[modifica]Esempio
#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}