Union declaration
Aus 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. |
This section is incomplete Reason: Expand description and example |
Eine Gewerkschaft ist eine spezielle Klasse Typ, der alle seine Daten speichert Mitglieder in den gleichen Speicherplatz .
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.
Gewerkschaften können keine virtuellen Funktionen vererbt werden oder erben anderen Klassen .
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.
(bis C + +11) Unions kann nur POD (plain old data) Typen .
Original:
(bis C + +11) Unions can only contain POD (plain old data) 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.
(seit C++11) Wenn eine Gewerkschaft enthält eine nicht-POD Element, das eine benutzerdefinierte besondere Funktion hat (Konstruktor, Destruktor, Copy-Konstruktor oder Zuweisungsoperator) diese Funktion standardmäßig in der Gewerkschaft wird gelöscht und muss explizit durch den Benutzer definiert werden .
Original:
(seit 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.
Inhaltsverzeichnis |
[Bearbeiten] Syntax
union name { member_declarations } object_list (optional) ;
|
(1) | ||||||||
union { member_declarations } ;
|
(2) | ||||||||
[Bearbeiten] Erklärung
# Benannt Gewerkschaft
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.
# Anonymous Gewerkschaft
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.
[Bearbeiten] Anonymous Gewerkschaften
Mitglieder eines anonymen union sind von der umgebenden Gültigkeitsbereich als einzelne Variablen .
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.
Anonymous Gewerkschaften haben weitere Einschränkungen: Sie dürfen nur öffentliche Mitglieder haben und nicht Elementfunktionen .
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-scope anonymen Gewerkschaften müssen statisch sein .
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.
[Bearbeiten] Beispiel
Output:
as int: 1024 as char: 128
(Für Little-Endian-Prozessoren)
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.