Reference: http://blog.csdn.net/zhangxinrun/article/details/5940019
New operator:
The example is as follows: int * Pint=new int (23); It allocates memory space on the heap, initializes the memory space, and finally returns the pointer.
For this operation to be overloaded, remember that it can only be overloaded in the class, get an overloaded version of placement new (old version is operator new), prototype as follows void *operator new (size_t, void *p) throw () {RE Turn p; }, Applied: MyClass * PCLASS=NEW (P) Int (23), formal and original is different, its function is simply to implement the existing memory of the pointer p on the construction of an int object.
Comparison:
Obviously there is less memory space allocation process, saving the process of memory search; As for memory applications, there can be other functions to do, such as using the previous new, but only in its space to re-specify, and do not need to destroy, redistribution again.
Attention:
Here the memory can be in the heap, of course, it can be in the stack, here is new, for new[], delete, delete[] are similar to the processing.
Placement new operator Learning in C + +