“placement new” advantage scenarios [duplicate]
问题 This question already has answers here : What uses are there for “placement new”? (22 answers) Closed 5 years ago . I have two cases for allocation of memory using new operator. class xx{ public: int x; xx(){} ~xx(){} }; class yy : public xx { public: int y; yy(){} ~yy(){} }; int main(int argc, char *argv[]) { yy *y1 = new yy(); //y1 constructor is called //CASE-1 yy *y2 = y1; //CASE-2 yy *y3 = new (y1) yy(); return 0; } In CASE-1 I am just allocating y1 memory to y2 without destroying y1