Namensräume
Varianten
Aktionen

new expression

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.
new expression
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
 
Initialisiert Objekte dynamisch erhalten Speicher .
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.
Dort eingesetzt, wo Daten dynamisch zugewiesen werden müssen, das heißt, ohne zu wissen, seine Größe vor der Zusammenstellung .
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.

Inhaltsverzeichnis

[Bearbeiten] Syntax

::(optional) new  type [array_n](optional) (init_params)(optional) (1)
::(optional) new (type ) [array_n](optional) (init_params)(optional) (2)
::(optional) new (placement_params)  type [array_n](optional) (init_params)(optional) (3)
::(optional)    new      (placement_params)     (type )     [array_n](optional)     (init_params)(optional)     (4)
Alle Versionen geben ein Objekt vom Typ' 'type * .
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.

[Bearbeiten] Erklärung

Die new Ausdruck weist einen Speicherbereich initialisiert entweder einzelnes Objekt oder ein Array von Objekten gibt und gibt einen Zeiger auf das erste konstruiertes Objekt. Da es nicht anders möglich explizit aufrufen rufen Sie einen Konstruktor, ist der Ausdruck der einzige Weg, um ein Objekt dynamisch zu konstruieren .
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.
Die ersten beiden und die letzten beiden Versionen des Ausdrucks nur syntaktisch unterscheiden. Das Verhalten ist das gleiche .
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.

[Bearbeiten] Speicherzuweisung

Der Speicher wird durch eine Allokation Funktion zugeordnet, entweder operator new oder operator new[] .
Original:
The memory is allocated by an Allokation Funktion, 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.
Die letzten beiden Versionen des Ausdrucks werden als' 'placement neue und werden verwendet, um zusätzliche Parameter (placement_params) die Zuteilung Funktion übergeben .
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.
Wenn array_n abwesend ist, wird der Speicher für ein einzelnes Objekt durch Aufruf operator new Allokation Funktion zugeordnet. Ansonsten Speicher für ein Array von array_n Objekten wird durch den Aufruf operator new[] Zuteilungsfunktion zugeordnet. Man beachte, dass mehr als size_of( type ) * array_n möglicherweise aufgrund von Zusatzinformationen von dem Compiler kodiert (z. B. die Größe des Arrays, da diese Informationen benötigt, um die Objekte destruct im Array richtig) zugeordnet werden .
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.
Die Zuordnung Funktion wird der Name zunächst in der lokalen Klasse type Rahmen gesucht und nur dann, wenn die Suche fehlschlägt, wird die globale Namensraum wird blickte auf. Wenn :: in der new Ausdruck ist, wird nur die globalen Namensraum blickte auf. Der Prototyp der Funktion sollte wie folgt aussehen, um die Zuteilung Funktion gewählt werden:
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 ist Byteanzahl zuzuweisen, sind die Parameter angegeben placement_params der Platzierung' neuen Ausdruck .
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.
[Bearbeiten] Standard-Implementierungen und Überlastung
Mehrere Standard-Zuweisung Funktionen sind implizit in jeder Übersetzungseinheit erklärt. Außerdem sind impliziten Implementierungen vom Compiler standardmäßig vorgesehen, es sei denn, das Programm hat sie ausdrücklich umgesetzt. Diese Funktionen sind wie folgt (siehe dies für weitere Informationen):
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 dies 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)
ordnet angeforderte Anzahl von Bytes oder wirft std::bad_alloc im Fehlerfall
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)
ordnet angeforderte Anzahl von Bytes oder kehrt NULL im Fehlerfall
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)
Renditen ptr. Dies erlaubt es, ein Objekt in vom Benutzer bereitgestellten Speicherbereich zu konstruieren. Das Programm muss nicht definieren explizite Implementierungen für diese Funktionen .
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.

[Bearbeiten] Object Initialisierung

Wenn array_n fehlt, wird einzelnes Objekt in der erworbenen Speicherbereich initialisiert, vorbei init_params als Parameter an den Konstruktor oder Aufrufen Standardkonstruktor, wenn sie nicht vorhanden sind .
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.
Wenn array_n vorhanden ist, wird eine Reihe von array_n Objekte initialisiert, vorbei init_params als Parameter an den Konstruktor für jedes Objekt oder den Aufruf Standardkonstruktor, wenn init_params nicht vorhanden sind .
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.

[Bearbeiten] Keywords

new