Line of code:
B* b = new (a) B(some initial values...);
Uses "post new" .
Default behavior; it creates a new object of type B in the same memory location as object a . If there are associated overloads for the new placement, then the behavior will be the same as in the case of overload, which may also include the default behavior of the type.
The code must be taken into account for any overloads , the memory layout of objects, and how classes a and B relate to each other.
It is unusual to create an object above the location of a previously created object. I would suggest that there is some code between the two that deconstructs (but still leaves the allocated memory) the previous object a before building a new one in its place.
The isocpp FAQ contains additional tips for using this technique and its dangers.
Niall source share