- new calls constructors, while malloc() does not. new operator allocates memory then calls the constructor.
- new is an operator, while malloc() is a function.
- new returns exact data type, while malloc() returns void *.
- We are allowed to override new operator where as we can not override the malloc() function legally.
- Required size of memory is calculated by compiler for new, where as we have to manually calculate size for malloc().
- new throws an exception on error, malloc returns NULL and sets errno.
Sharing is Caring !
Subscribe
0 Comments
Most Voted