zero initialization

Da cppreference.com.
< cpp‎ | language

 
 
Linguaggio C + +
Temi generali
Original:
General topics
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Controllo del flusso
Original:
Flow control
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Dichiarazioni esecuzione condizionale
Original:
Conditional execution statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Iterazione dichiarazioni
Original:
Iteration statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Vai dichiarazioni
Original:
Jump statements
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funzioni
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
dichiarazione di funzione
lambda funzione dichiarazione
funzione di modello
specificatore inline
eccezioni specifiche(deprecato)
noexcept specificatore(C++11)
Eccezioni
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Spazi dei nomi
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipi
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
decltype specifier(C++11)
Specifiers
Original:
Specifiers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
cv specificatori
Durata di stoccaggio specificatori
constexpr specificatore(C++11)
specificatore auto(C++11)
alignas specificatore(C++11)
Inizializzazione
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Letterali
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Espressioni
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rappresentazioni alternative
Utilities
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipi
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
typedef declaration
Tipo alias dichiarazione(C++11)
attributi(C++11)
Lancia
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversioni implicite
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
Fusione C-stile e funzionale
Occupazione della memoria
Original:
Memory allocation
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Classi
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Specifiche per una classe di funzioni proprietà
Original:
Class-specific function properties
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funzioni membro speciali
Original:
Special member functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Modelli
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
classe template
funzione di modello
modello di specializzazione
parametri confezioni(C++11)
Varie
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Montaggio in linea
 
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.

Indice

[modifica]Sintassi

staticTobject; (1)
int(); (2)
chararray[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.
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.
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.
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.
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.
  • Se T è un tipo scalare, il valore iniziale dell'oggetto è il conversione implicita integrale costante zero a T.
    Original:
    If T is a scalar type, the object's initial value is the integral constant zero conversione implicita to T.
    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:
    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.
  • 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:
    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.
  • Se T è di tipo array, ogni elemento è zero-inizializzato
    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.
  • Se è T tipo di riferimento, non si fa nulla.
    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.

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

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


[modifica]Vedi anche

close