Dynamic memory allocation (new delete malloc free)

What is the difference between new and malloc?
-new keywords are part of C ++, are supported in all C ++ compiler
-malloc is a function provided by the C library, in some system development it can not be called
-new to specific types of units of memory allocation
- malloc single file in bytes memory allocation
-new at the time of application memory space can be initialized, it will trigger a call to the constructor
-malloc only apply quantitative memory space as needed
- can only be used to create objects new new
-malloc not suitable object-oriented development

What is the difference between delete and free?
-delete are supported in all C ++ compiler
-free In some systems development can not be called
-delete can trigger a call to the destructor of
previously allocated memory space -free only return
- the destruction of the object can only use the Delete
- free is not suitable for object-oriented development

Guess you like

Origin www.cnblogs.com/-glb/p/11973247.html