View Single Post
Go4Expert Founder
28Feb2005,17:02  
shabbir's Avatar
Just got a Mail from a user asking for a question as and thought also after answering him would like to share the same with Expert Advice Forums member

Why should I use new and not malloc()?

» Constructors/destructors:
New and Delete makes sure that constructors and Destructors are called but not the case with malloc and free functions of C.
» Pointer conversion safety:
malloc() returns a void* which isn't safe. new returns a pointer of the right type.
» new is a Operator:
new is an operator that can be overloaded for better memory management by a class, while malloc() is not an operaotor.