Suchergebnisse für Anfrage "placement-new"

4 die antwort

Überschreiben eines Objekts mit einem Objekt des gleichen Typs

Ist das Folgende gut definiert? #include <iostream> #include <string.h> using namespace std; struct Const { const int i; Const (int i) : i(i) {} int get0() { return 0; } // best accessor ever! }; int main() { Const *q,*p = new Const(1); new (p) ...

20 die antwort

Wie wird das C ++ - Konstrukt "placement new" verwendet?

Ich habe gerade das C ++ - Konstrukt "placement new" kennengelernt. Hiermit können Sie genau steuern, wohin ein Zeiger im Speicher zeigt. Es sieht aus wie das #include <new> // Must #include this to use "placement new" #include "Fred.h" ...

12 die antwort

Was ist ein In-Place-Konstruktor in C ++? [Duplikat

Mögliches Duplizieren: C ++ 's "Platzierung neu" [https://stackoverflow.com/questions/222557/cs-placement-new] Was ist ein In-Place-Konstruktor in C ++? z.B. Datentyp * x = new (y) Datentyp ();

TOP-Veröffentlichungen

8 die antwort

Wie weiß Placement New, welches Layout erstellt werden soll?

#include <iostream> #include <typeinfo> struct A { int a; }; struct B : virtual A { int b; }; struct C : virtual A { int c; }; struct D : B,C { int d; }; int main() { D complete; B contiguous; B & separate = complete; B * p[2] = {&separate, ...