Compare Malloc/free and New/delete
?? When it comes to memory allocation, it is common to use malloc with Free.malloc and free as the standard library function for C++/C, New/delete is the C + + operator. They can all be used to request dynamic memory and free memory.
?? For objects of non-intrinsic data types, light Malloc/free cannot meet the requirements of dynamic objects. Objects are automatically executed when they are created, and the object executes the destructor automatically before it dies. Because Malloc/free is a library function and not an operator, the task of executing constructors and destructors cannot be imposed on malloc/free, not within the control of the compiler.
?? Therefore, C + + requires an operator new that can perform dynamic memory allocation and initialization, and an operator delete that can perform cleanup and freeing of memory work.
Copyright NOTICE: This article for csdn bo Master [Applebite] (Http://blog.csdn.net/applebite) original articles, reproduced please indicate the source, infringement must be studied.
Compare Malloc/free and New/delete