Distinguish between new and malloc and delete and free().Delete is assocated with new and free(0 is associated with malloc().
New : - It's an operator - Delete is associated with new - It creates an object - It throws exceptions if memory is unavailable - Operator new can be overloaded - You can state the number of objects to be created.
malloc() : - It’s a function. - free() is associated with malloc(). - It does not create objects. - It returns NULL. - This cannot be overloaded. - You need to specify the number of bytes to be allocated.
|