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. |
Establece el valor inicial de un objeto a cero
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.
Contenido |
[editar] Sintaxis
static T object ;
|
(1) | ||||||||
int () ;
|
(2) | ||||||||
char array [ n ] = "";
|
(3) | ||||||||
[editar] Explicación
Zero inicialización se realiza en las siguientes situaciones:
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)
Para cada variable llamada con duración de almacenamiento estático o local de subprocesos, antes de cualquier otra inicialización .
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)
Como parte de la secuencia de valor de inicialización por falta de tipos de clase y para los miembros de valor inicializado tipos de clases que no tienen constructores .
Original:
As part of valor de inicialización 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)
Cuando una matriz de caracteres es inicializada con una cadena literal que es demasiado corto, el resto de la matriz es cero inicializa .
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.
Los efectos de inicialización de cero son:
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
es un tipo escalar, el valor inicial del objeto es el convertir implícitamente integral constante cero aT
.Original:IfT
is a scalar type, the object's initial value is the integral constant zero convertir implícitamente 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
es un tipo de clase no-unión, todas las clases de base y los miembros no estáticos de datos son inicializarse en cero, y todo el relleno se inicializa a cero bits. Los constructores, en su caso, se ignoran .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
es un tipo de unión, el primer miembro no estático de datos con nombre es inicializarse en cero y todo el relleno se inicializa a cero 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 es
T
tipo de matriz, cada elemento es cero inicializaOriginal: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
es el tipo de referencia, no se hace nada .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.
[editar] Notas
Las variables estáticas y locales son los primeros hilos inicializarse en cero y luego otra vez inicializada según lo especificado en el programa, por ejemplo, una función estática-local es el primero inicializarse en cero al inicio del programa, y luego su constructor se llama cuando la función se entró por primera vez. Si la declaración de una clase estática no tiene ningún inicializador, luego de inicialización por defecto no hace nada, dejando el resultado de la anterior cero inicialización sin modificar .
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 puntero inicializarse en cero es el valor de puntero nulo de su tipo, incluso si el valor del puntero nulo no es cero integral .
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.
[editar] Ejemplo
#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 }