Espaços nominais
Variantes
Acções

Initializer list

Da cppreference.com
< cpp‎ | language

 
 
Linguagem C++
Tópicos gerais
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.
Controle de fluxo
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.
Declarações execução condicional
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.
Instruções de iteração
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.
Ir declarações
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.
Funções
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declaração da função
lambda declaração da função
modelo de função
linha especificador
especificações de exceção(obsoleta)
noexcept especificador(C++11)
Exceções
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Namespaces
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos
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)
Especificadores
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 especificadores
armazenamento duração especificadores
constexpr especificador(C++11)
auto especificador(C++11)
alignas especificador(C++11)
Inicialização
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literais
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressões
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
representações alternativas
Utilitários
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipos
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 de alias declaração(C++11)
atributos(C++11)
Conversões
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversões implícitas
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
Elenco C-estilo e funcional
Alocação de memória
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.
Classes
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
amigo especificador
listas inicializador
Classe propriedades específicas de função
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.
Funções membro especiais
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.
Modelos
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
modelo de classe
modelo de função
especialização de modelo
pacotes de parâmetros(C++11)
Diversos
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Assembly embutido
 
(Não deve ser confundido com 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.
Eles são parte de um construtor que é responsável pela inicialização membro e ancestral
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.

[editar]Sintaxe

constructor_signature:member_constructor_calls{constructor_body}

[editar]Explicação

A lista de inicializador é o lugar onde a inicialização do objeto deverá ocorrer, não é onde os construtores para classes de base e os membros são chamados.
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.
Membros são inicializados na mesma ordem em que são declarados, não como eles aparecem na lista de inicializador.
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.
Se um parâmetro no construtor tem o mesmo nome de um dos membros, a ambigüidade do que identificador que está sendo passado em uma chamada de construtor dentro da lista intializer é resolvido escolha do parâmetro (e não o membro).
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.
Membros ou classes de base não está presente na lista será padrão construído
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.

[editar]Exemplo

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}};
close