Distinguish between new and malloc and delete and free().

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.
What is the difference between realloc() and free()? - C++
Difference between realloc() and free() - An existing block of memory which was allocated by malloc() subroutine, will be freed by free() subroutine.....
What is function overloading and operator overloading? - C++
What is function overloading and operator overloading? - C++ provides ability to overload most operators so that they perform special operations relative to classes.....
What is overloading unary operator? - C++
What is overloading unary operator? - Unary operators are those which operate on a single variable....
Post your comment