Namespace
Varianti

enumeration declaration

Da cppreference.com.
< cpp‎ | language

 
 
Linguaggio C + +
Temi generali
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.
Controllo del flusso
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.
Dichiarazioni esecuzione condizionale
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.
Iterazione dichiarazioni
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.
Vai dichiarazioni
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.
Funzioni
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
dichiarazione di funzione
lambda funzione dichiarazione
funzione di modello
specificatore inline
eccezioni specifiche (deprecato)
noexcept specificatore (C++11)
Eccezioni
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Spazi dei nomi
Original:
Namespaces
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Tipi
Original:
Types
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
tipi fondamentali
composti tipi
enumerazione tipi
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 specificatori
Durata di stoccaggio specificatori
constexpr specificatore (C++11)
specificatore auto (C++11)
alignas specificatore (C++11)
Inizializzazione
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Letterali
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Espressioni
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
rappresentazioni alternative
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.
Tipi
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 alias dichiarazione (C++11)
attributi (C++11)
Lancia
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversioni implicite
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
Fusione C-stile e funzionale
Occupazione della memoria
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.
Classi
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Specifiche per una classe di funzioni proprietà
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.
esplicito (C++11)
statico
Funzioni membro speciali
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.
Modelli
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
classe template
funzione di modello
modello di specializzazione
parametri confezioni (C++11)
Varie
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Montaggio in linea
 
Un'enumerazione è un tipo distinto il cui valore è limitato a una delle numerose costanti indicati esplicitamente ("enumeratori"). I valori delle costanti sono valori di un tipo integrale noto come tipo sottostante dell'enumerazione.
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) (dal C++11)
enum struct name : type attr { enumerator = constexpr , enumerator = constexpr , ... None} (3) (dal C++11)
1)
dichiara un tipo di enumerazione senza ambito. Ogni enumerator diventa accessibile nel campo di applicazione racchiude, ed è implicitamente convertibile tipo integrale, compreso bool. Se non espressamente specificato, il tipo di fondo è un tipo integrale in grado di rappresentare tutti i valori di enumerazione, che non possono essere più ampio di quello int a meno che qualche constexpr restituisce una costante che non rientra in una int
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)
dichiara un tipo di ambito di enumerazione. Ogni enumerator accessibile solo come name::enumerator. Conversione a tipi integrali è possibile con static_cast. Se non espressamente specificato, il tipo di fondo è 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.

[modifica] Spiegazione

name -
il nome del tipo dichiarato da questa dichiarazione. Un'enumerazione senza ambito possono essere senza nome, nel qual caso si introduce solo nomi enumeratore come costanti, ma nessun nuovo tipo
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) -
opzionale di tipo integrale (qualsiasi cv-qualificazione è ignorato), utilizzato come il tipo sottostante dell'enumerazione .
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) -
zero o più attributi specifici di attuazione del [[attribute]] forma
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 -
zero o più enumeratori che vengono introdotte con la presente dichiarazione. I nomi dei enumeratori possono essere usati ovunque costanti sono attesi
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 -
di espressione opzionale costante che restituisce il valore da assegnare al enumeratore. Se viene omesso, il valore è il valore dell'enumeratore precedente più 1. Se omesso per l'enumeratore primo, il valore è 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.

[modifica] Esempio

#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