Initializer list
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. |
(No debe confundirse con std :: initializer_list)
Original:
( Not to be confused with std :: initializer_list )
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.
Ellos son parte de un constructor que es responsable de miembro y la inicialización antepasado
Original:
They are the part of a constructor which is responsible for member and ancestor 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.
[editar] Sintaxis
constructor_signature : member_constructor_calls { constructor_body }
|
|||||||||
[editar] Explicación
La lista de inicialización es el lugar donde la inicialización del objeto ocurre, ahí es donde los constructores de clases base y los miembros se llaman .
Original:
The initializer list is the place where initialization of the object should occur, there is where the constructors for base classes and members are called.
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 miembros se inicializan en el mismo orden en que se declaran no, tal y como aparecen en la lista de inicialización .
Original:
Members are initialized in the same order as they are declared, not as they appear in the initializer list.
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 un parámetro en el constructor tiene el mismo nombre que uno de los miembros, la ambigüedad de ese identificador que se pasa en una llamada de constructor dentro de la lista intializer se resuelve la elección del parámetro (y no miembros) .
Original:
If a parameter in the constructor has the same name as one of the members, the ambiguity of that identifier being passed in a constructor call inside the intializer list is resolved choosing the parameter (and not the member).
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 miembros o clases base no presentes en la lista será construido por defecto
Original:
Members or base classes not present in the list will be default constructed
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
struct Class : public Base { int x; int y; Class ( int x ) : Base ( 123 ), // initialize base class x ( x ), // x (member) is initialized with x (parameter) y ( 0 ) // y initialized to 0 {} // empty constructor body Class ( double a ) : y ( a+1 ), x ( y ) // x will be initialized before y, this means that its value here is undefined {} // No base class constructor in list, this is the same as calling Base() Class() try : Base ( 789 ), x ( 0 ), y ( 0 ) { // no exception } catch (...) { // exception occurred on initialization } };

