Espacios de nombres
Variantes
Acciones

enumeration declaration

De cppreference.com
< cpp‎ | language

 
 
Lenguaje C++
Los temas generales
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.
Control de flujo
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.
Sentencias condicionales ejecución
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.
Instrucciones de iteración
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 declaraciones
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.
Funciones
Original:
Functions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
declaración de la función
lambda declaración de la función
función de plantilla
especificador inline
especificaciones de excepción (obsoleto)
noexcept especificador (C++11)
Excepciones
Original:
Exceptions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Los espacios de nombres
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.
tipos fundamentales
tipos de compuestos
los tipos de enumeración
decltype specifier (C++11)
Los 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
almacenamiento duración especificadores
constexpr especificador (C++11)
auto especificador (C++11)
alignas especificador (C++11)
Inicialización
Original:
Initialization
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Los literales
Original:
Literals
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Expresiones
Original:
Expressions
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
representaciones alternativas
Utilidades
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
alias de tipo de declaración (C++11)
atributos (C++11)
Lanza
Original:
Casts
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
conversiones implícitas
const_cast conversion
static_cast conversion
dynamic_cast conversion
reinterpret_cast conversion
C-cast estilo y funcional
De asignación de 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.
Clases
Original:
Classes
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Clase propiedades específicas de la función
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.
Funciones especiales miembro
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.
Plantillas
Original:
Templates
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
clase de plantilla
función de plantilla
plantilla de especialización
paquetes de parámetros (C++11)
Varios
Original:
Miscellaneous
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Montaje en línea
 
Una enumeración es un tipo diferenciado cuyo valor se limita a una de las varias constantes explícitamente con nombre ("encuestadores"). Los valores de las constantes son valores de un tipo integral conocido como el tipo subyacente de la enumeración .
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) (desde C++11)
enum struct name : type attr { enumerator = constexpr , enumerator = constexpr , ... None} (3) (desde C++11)
1)
declara un tipo de enumeración sin ámbito. Cada enumerator se hace accesible en el ámbito circundante, y es implícitamente convertible al tipo integral, incluyendo bool. Si no se especifica, el tipo subyacente es un tipo integral capaz de representar todos los valores de enumerador, que no puede ser más amplio que int a menos que algún constexpr se evalúa como una constante que no cabe en un 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)
declara un tipo de enumeración ámbito. Cada enumerator sólo se puede acceder como name::enumerator. La conversión a tipos integrales es posible con static_cast. Si no se especifica, el tipo de fondo es 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.

[editar] Explicación

name -
el nombre del tipo declarado en la presente declaración. Una enumeración sin ámbito puede ser sin nombre, en cuyo caso sólo introduce los nombres de enumerador como constantes, pero no nuevo 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) -
tipo integral opcional (cualquier cv-calificación se ignora), usado como el tipo subyacente de la enumeración .
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) -
cero o más atributos específicos de la implementación de la [[attribute]] formulario
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 -
cero o más enumeradores que se introducen por la presente declaración. Los nombres de los enumeradores pueden utilizarse en cualquier lugar constantes se esperaba
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 -
expresión opcional constante que se evalúa como el valor que se asigna al enumerador. Si se omite, el valor es el valor del enumerador anterior más 1. Si se omite para el empadronador primero, el valor es 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.

[editar] Ejemplo

#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