Namensräume
Varianten
Aktionen

enumeration declaration

Aus cppreference.com
< cpp‎ | language

 
 
Sprache C + +
Allgemeine Themen
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.
Flusskontrolle
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.
Bedingte Ausführung Aussagen
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.
Iterationsanweisungen
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.
Gehe Aussagen
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.
Funktionen
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Funktion Erklärung
Lambda-Funktion Erklärung
Funktions-Template
inline-Spezifizierer
Exception-Spezifikationen (veraltet)
noexcept Spezifizierer (C++11)
Ausnahmen
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.
Types
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)
Specifiers
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 Planer
Lagerdauer Planer
constexpr Spezifizierer (C++11)
auto Spezifizierer (C++11)
alignas Spezifizierer (C++11)
Initialisierung
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Literale
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expressions
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
alternative Darstellungen
Utilities
Original:
Utilities
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Types
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
Typ Aliasdeklaration (C++11)
Attribute (C++11)
Wirft
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
impliziten Konvertierungen
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-Stil und funktionale Besetzung
Speicherzuweisung
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.
Class-spezifische Funktion Eigenschaften
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.
explizit (C++11)
statisch
Besondere Member-Funktionen
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.
Templates
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Klassen-Template
Funktions-Template
Template-Spezialisierung
Parameter Packs (C++11)
Verschiedenes
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Inline Montage
 
Eine Enumeration ist eine deutliche Art, deren Wert sich auf eine von mehreren explizit benannte Konstanten ("Enumeratoren") beschränkt. Die Werte der Konstanten sind Werte eines integralen Typs wie der zugrunde liegenden Typ der Aufzählung bekannt .
Original:
An enumeration is a distinct type whose value is restricted to one of several explicitly named constants ("enumerators"). The values of the constants are values of an integral type known as the underlying type of the enumeration.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
enum name : type attr { enumerator = constexpr , enumerator = constexpr , ... None} (1)
enum class name : type attr { enumerator = constexpr , enumerator = constexpr , ... None} (2) (seit C++11)
enum struct name : type attr { enumerator = constexpr , enumerator = constexpr , ... None} (3) (seit C++11)
1)
erklärt, eine ohne Bereichseinschränkung Aufzählungstyp. Jeder enumerator zugänglich wird im umschließenden Gültigkeitsbereich und ist implizit konvertierbar integraler Typ, einschließlich bool. Wenn nicht ausdrücklich angegeben wird, ist der zugrunde liegende Typ ein integraler Typ, der stellvertretend für alle Enumerator Werte, die nicht breiter als int es sei denn, einige constexpr ergibt eine Konstante, die nicht in einem int nicht passen
Original:
declares an unscoped enumeration type. Each enumerator becomes accessible in the enclosing scope, and is implicitly-convertible to integral type, including bool. If not explicitly specified, the underlying type is an integral type capable of representing all enumerator values, which cannot be wider than int unless some constexpr evaluates to a constant that does not fit in an int
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
2-3)
deklariert eine scoped Aufzählungstyp. Jedes enumerator kann nur als name::enumerator genutzt werden. Umstellung auf ganzzahligen Typen ist möglich mit static_cast. Wenn nicht ausdrücklich angegeben wird, ist der zugrunde liegende Typ int .
Original:
declares a scoped enumeration type. Each enumerator can only be accessed as name::enumerator. Conversion to integral types is possible with static_cast. If not explicitly specified, the underlying type is int.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Erklärung

name -
der Name des Typs deklariert diese Erklärung. Eine Aufzählung kann ohne Bereichseinschränkung namenlos, in welchem ​​Fall es nur einführt Enumerator Namen als Konstanten, aber keinen neuen Typ
Original:
the name of the type declared by this declaration. An unscoped enumeration may be nameless, in which case it only introduces enumerator names as constants, but no new type
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
type(C++11) -
optional ganzzahligen Typ (alle cv-Qualifikation wird ignoriert), wie die zugrunde liegenden Typ der Enumeration verwendet .
Original:
optional integral type (any cv-qualification is ignored), used as the underlying type of the enumeration.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
attr(C++11) -
null oder mehr die Implementierung spezifischer Attribute des Formulars [[attribute]]
Original:
zero or more implementation-specific attributes of the form [[attribute]]
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
enumerator -
null oder mehr Zähler, die von dieser Erklärung eingeführt werden. Die Namen der Enumeratoren kann überall dort eingesetzt werden Konstanten erwartet werden
Original:
zero or more enumerators which are introduced by this declaration. The names of the enumerators may be used anywhere constants are expected
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
constexpr -
optional konstanter Ausdruck, welche wertet den Wert, um den Enumerator zugewiesen werden. Wenn er nicht angegeben, wird der Wert der Wert des vorherigen Enumerator sowie 1. Wenn zum ersten Enumerator weggelassen wird, ist der Wert 0
Original:
optional constant expression which evaluates to the value to be assigned to the enumerator. If it is omitted, the value is the value of the previous enumerator plus 1. If omitted for the first enumerator, the value is 0
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[Bearbeiten] Beispiel

#include <iostream>
// color may be red (value 0), yellow (value 1), green (value 20), or blue (value 21)
enum color {
    red,
    yellow,
    green = 20,
    blue
};
// altitude may be altitude::high or altitude::low
enum class altitude : char { 
     high='h',
     low='l', // C++11 allows the extra comma
}; 
// the constant d is 0, the constant e is 1, the constant f is 3
enum { d, e, f=e+2 };
int main()
{
    color col = red;
    altitude a;
    a = altitude::low;
 
    std::cout << "red = " << col << " blue = " << blue << '\n'
              << "a = " << static_cast<char>(a) << '\n'
              << "f = " << f << '\n';
}

Output:

red = 0 blue = 21
a = l
f = 3