DIR Return Create A Forum - Home
---------------------------------------------------------
ifaq
HTML https://ifaq.createaforum.com
---------------------------------------------------------
*****************************************************
DIR Return to: C/C++ related questions
*****************************************************
#Post#: 4--------------------------------------------------
new operator vs malloc()
By: avinash.srin Date: August 25, 2011, 9:29 am
---------------------------------------------------------
What's the difference between new operator and malloc() ? List
as many differences as you can.
#Post#: 20--------------------------------------------------
Re: new operator vs malloc()
By: avinash.srin Date: August 26, 2011, 6:40 am
---------------------------------------------------------
1. new is an operator, malloc() is a function
2. new returns objects of a specific type, malloc() returns
void*
3. new invokes constructor, malloc() doesn't
4. bad_alloc exception is thrown by new if unable to allocate
space on heap, malloc() returns null pointer if unable to
allocate space on heap
*****************************************************