Namespace
Varianti

new expression

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.
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.
new expression
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
 
Inizializza gli oggetti nella memoria in modo dinamico ottenuto.
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.
Usato in cui i dati devono essere assegnate in modo dinamico, cioè senza conoscere le sue dimensioni prima della compilazione.
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.

Indice

[modifica] Sintassi

::(opzionale) new  type [array_n](opzionale) (init_params)(opzionale) (1)
::(opzionale) new (type ) [array_n](opzionale) (init_params)(opzionale) (2)
::(opzionale) new (placement_params)  type [array_n](opzionale) (init_params)(opzionale) (3)
::(opzionale)    new      (placement_params)     (type )     [array_n](opzionale)     (init_params)(opzionale)     (4)
Tutte le versioni restituire un oggetto di 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.

[modifica] Spiegazione

L'espressione new alloca un'area di memoria, inizializza o singolo oggetto, o un array di oggetti lì e restituisce un puntatore al primo oggetto costruito. Dal momento che non sia altrimenti possibile chiamare esplicitamente chiamare un costruttore, l'espressione è l'unico modo per costruire un oggetto in modo dinamico.
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.
Le prime due e le ultime due versioni di espressione differiscono solo sintatticamente. Il comportamento è lo stesso.
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.

[modifica] Occupazione della memoria

La memoria viene assegnata dal assegnazione della funzione, sia operator new o operator new[].
Original:
The memory is allocated by an assegnazione della funzione, 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.
Le ultime due versioni di espressione sono chiamati' 'di collocamento e sono usati per passare parametri aggiuntivi (placement_params) alla funzione di assegnazione.
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.
Se array_n è assente, la memoria viene allocata per un singolo oggetto richiamando allocazione operator new funzione. In caso contrario, la memoria per un array di oggetti array_n è assegnato chiamando allocazione operator new[] funzione. Nota, che più size_of( type ) * array_n potrebbero essere assegnate a causa di informazioni aggiuntive codificate dal compilatore (ad esempio la dimensione della matrice, poiché questa informazione è necessaria per distruggere gli oggetti nella matrice correttamente).
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.
Il nome della funzione di assegnazione è in primo luogo cercato nel locale classe tipo ambito di applicazione e solo se la ricerca ha esito negativo, lo spazio dei nomi globale viene cercato. Se :: è presente nell'espressione new, solo lo spazio dei nomi globale viene cercato. Il prototipo della funzione dovrebbe essere simile a quanto segue in ordine alla funzione di allocazione da selezionare:
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 è il numero di byte da allocare, placement_params sono i parametri indicati al collocamento nuova espressione.
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.
[modifica] Le implementazioni predefinite e sovraccarichi
Diverse funzioni di allocazione di default sono implicitamente dichiarate in ogni unità di traduzione. Inoltre, le implementazioni impliciti sono forniti dal compilatore di default, a meno che il programma è implementato in modo esplicito. Le funzioni sono le seguenti (vedi questo per maggiori informazioni):
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 questo 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)
alloca chiesto il numero di byte o getta std::bad_alloc in caso di fallimento
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)
alloca richiesto numero di byte o NULL rendimenti in caso di fallimento
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)
ritorna ptr. Questo permette di costruire un oggetto in fornito dall'utente area di memoria. Il programma non deve definire implementazioni esplicite di queste funzioni.
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.

[modifica] Oggetto inizializzazione

Se array_n è assente, singolo oggetto viene inizializzato nella zona di memoria acquisita, passando init_params come parametri al costruttore o invocando costruttore di default, se non sono presenti.
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.
Se array_n è presente, una matrice di oggetti array_n viene inizializzata, passando init_params come parametri al costruttore di ogni oggetto o invocare costruttore predefinito se init_params non sono presenti.
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.

[modifica] Parole chiave

new