Espacios de nombres
Variantes
Acciones

new expression

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.
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.
new expression
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
 
Inicializa los objetos en memoria dinámica obtenida .
Original:
Initializes objects in dynamically obtained memory.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Se utiliza cuando los datos deben ser asignados de forma dinámica, es decir, sin conocer su tamaño antes de la compilación .
Original:
Used where data need to be allocated dynamically, that is, without knowing its size prior the compilation.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

Contenido

[editar] Sintaxis

::(opcional) new  type [array_n](opcional) (init_params)(opcional) (1)
::(opcional) new (type ) [array_n](opcional) (init_params)(opcional) (2)
::(opcional) new (placement_params)  type [array_n](opcional) (init_params)(opcional) (3)
::(opcional)    new      (placement_params)     (type )     [array_n](opcional)     (init_params)(opcional)     (4)
Todas las versiones devolver un objeto de tipo' '* tipo .
Original:
All versions return an object of type type *.
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

La expresión new asigna un área de memoria, inicializa ya sea solo objeto, o un conjunto de objetos hay y devuelve un puntero al primer objeto construido. Dado que no es posible de otra manera de llamar explícitamente a un constructor, la expresión es la única manera de construir un objeto de forma dinámica .
Original:
The new expression allocates a memory area, initializes either single object, or an array of objects there and returns a pointer to the first constructed object. Since it is not otherwise possible to call explicitly call a constructor, the expression is the only way to construct an object dynamically.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Las dos primeras y las dos últimas versiones de la expresión sólo difieren sintácticamente. El comportamiento es el mismo .
Original:
The first two and last two versions of the expression differ only syntactically. The behavior is the same.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] De asignación de memoria

La memoria es asignada por un asignación de función, ya sea operator new o operator new[] .
Original:
The memory is allocated by an asignación de función, either operator new or operator new[].
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Las dos últimas versiones de la expresión se llaman' 'nueva colocación y se utilizan para pasar parámetros adicionales (placement_params) a la función de asignación .
Original:
The last two versions of the expression are called placement new and are used to pass additional parameters (placement_params) to the allocation function.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si array_n está ausente, se asigna memoria para un solo objeto al invocar la función operator new asignación. De lo contrario memoria para una matriz de objetos array_n se asigna llamando a la función operator new[] asignación. Nota, que más de size_of( type ) * array_n puede ser asignado debido a la información adicional codificada por el compilador (como el tamaño de la matriz, ya que esta información es necesaria con el fin de destruir los objetos de la matriz correctamente) .
Original:
If array_n is absent, memory is allocated for a single object by invoking operator new allocation function. Otherwise memory for an array of array_n objects is allocated by calling operator new[] allocation function. Note, that more than size_of( type ) * array_n might be allocated because of additional information encoded by the compiler (such as the size of the array, since this information is needed in order to destruct the objects in the array properly).
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
El nombre de la función de asignación se levantó en primer lugar en la categoría de local tipo alcance y sólo si la búsqueda falla, el espacio de nombres global se busca. Si :: está presente en la expresión new, sólo el espacio de nombres global se busca. El prototipo de la función debe ser similar a la siguiente en orden a la función de asignación que ha seleccionado:
Original:
The allocation function's name is firstly looked up in the local class type scope and only if the lookup fails, the global namespace is looked up. If :: is present in the new expression, only the global namespace is looked up. The prototype of the function should look like the following in order to the allocation function to be selected:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
void* operator new  (size_t count);
for versions 1, 2, array_n is not present
void* operator new[](size_t count);
for versions 1, 2, array_n is present
void* operator new  (size_t count/*, placement_params...*/);
for versions 3, 4 (placement new), array_n is not present
void* operator new[](size_t count/*, placement_params...*/);
for versions 3, 4 (placement new), array_n is present
count es el número de bytes a asignar, placement_params son los parámetros que se indican a la colocación expresión nuevo .
Original:
count is number of bytes to allocate, placement_params are the parameters given to the placement new expression.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
[editar] Las implementaciones por defecto y sobrecarga
Varias funciones de asignación por defecto se declara implícitamente en cada unidad de traducción. Además, las implementaciones implícitas son proporcionados por el compilador por defecto, a menos que el programa se ha implementado de forma explícita. Estas funciones son las siguientes (ver esto para más información):
Original:
Several default allocation functions are implicitly declared in each translation unit. Also, implicit implementations are provided by the compiler by default, unless the program has explicitly implemented them. These functions are as follows (see esto for more information):
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
void* operator new  (size_t);
(1)
void* operator new[](size_t);
(2)
void* operator new  (size_t, std::nothrow_t);
(3)
void* operator new[](size_t, std::nothrow_t);
(4)
void* operator new  (size_t, void* ptr);
(5)
void* operator new[](size_t, void* ptr);
(6)
1-2)
asigna el número de bytes requerido o lanza std::bad_alloc en caso de fallo
Original:
allocates requested number of bytes or throws std::bad_alloc on failure
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
3-4)
asigna solicitado número de bytes o NULL Regreso el fracaso
Original:
allocates requested number of bytes or returns NULL on failure
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
5-6)
vuelve ptr. Esto permite la construcción de un objeto en suministrada por el usuario área de memoria. El programa no debe definir implementaciones explícitas para estas funciones .
Original:
returns ptr. This allows to construct an object in user-supplied memory area. The program must not define explicit implementations for these functions.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Objeto de inicialización

Si array_n está ausente, solo objeto se inicializa en el área de la memoria adquirida, pasando init_params como parámetros al constructor o constructor invoca por defecto si no están presentes .
Original:
If array_n is absent, single object is initialized in the acquired memory area, passing init_params as parameters to the constructor or invoking default constructor if they are not present.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Si array_n está presente, un conjunto de objetos array_n se inicializa, pasando init_params como parámetros para el constructor de cada objeto o invocar constructor por defecto si no están presentes init_params .
Original:
If array_n is present, an array of array_n objects is initialized, passing init_params as parameters to the constructor of each object or invoking default constructor if init_params are not present.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.

[editar] Palabras clave

new