Wednesday, October 01, 2008

New/Delete advantages

Brushing through some basics:


  • new/delete invokes constructor/destructor. Malloc/free will not.
  • new does not need typcasting. Malloc requires typcasting the returned pointer.
  • new/delete operators can be overloaded, malloc/free can not.
  • new does not require you to explicitly calculate the quantity of memory required. (Unlike malloc)
Ref: C / C++ and Dynamic memory allocation