Union declaration
Da 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. |
Esta seção está incompleta Motivo: Expand description and example |
Uma união é um tipo de classe especial que armazena todos os seus membros de dados no mesmo local da memória.
Original:
A union is a special class type that stores all of its data members in the same memory location.
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.
Os sindicatos não podem ter funções virtuais, ser herdado ou herdar de outras classes.
Original:
Unions cannot have virtual functions, be inherited or inherit other classes.
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.
Sindicatos (até C++11) só pode conter tipos POD (plain dados antigos).
Original:
(até C++11) Unions can only contain POD (plain dados antigos) types.
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.
(desde C++11) Se uma união contém um membro não-POD, que tem uma função definida pelo usuário especial (construtor, destruidor construtor de cópia, ou de atribuição de cópia) que a função é excluído por padrão na união e precisa ser definida explicitamente pelo usuário.
Original:
(desde C++11) If a union contains a non-POD member, which has a user-defined special function (constructor, destructor, copy constructor or copy assignment) that function is deleted by default in the union and needs to be defined explicitly by the user.
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.
Índice |
[editar] Sintaxe
union name { member_declarations } object_list (opcional) ;
|
(1) | ||||||||
union { member_declarations } ;
|
(2) | ||||||||
[editar] Explicação
# Chamado união
Original:
#Named union
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.
União # Anonymous
Original:
#Anonymous union
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] Sindicatos anônimos
Membros de uma união anônima são acessíveis a partir do escopo encerrar, como as variáveis simples.
Original:
Members of an anonymous union are accessible from the enclosing scope as single variables.
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.
Sindicatos anônimos têm mais restrições: eles devem ter apenas os membros públicos e não pode ter funções membro.
Original:
Anonymous unions have further restrictions: they must have only public members and cannot have member functions.
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.
Namespace de escopo de sindicatos anônimos deve ser estático.
Original:
Namespace-scope anonymous unions must be static.
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] Exemplo
Saída:
as int: 1024 as char: 128
(Para little-endian processadores)
Original:
(for little-endian processors)
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.