+ 1
What is difference between new and malloc()?
If you're a C++ expert, please let me know any rules of thumb or conventions you follow in this regard.
1 Answer
+ 3
For the developer, the biggest and most important difference is that new will call an object's constructor, while malloc will not. Similarly, delete will call the destructor, while free will not. Free also cannot be used on memory allocated new, and vise versa.
In general the only usual reason to use malloc is if you are working with legacy code or overloading the `new` operator.