ProAnswers.org

Why should I use `new' instead of trustworthy old malloc()?

malloc() doesn’t call constructors, and free() doesn’t call destructors.
Besides, malloc() isn’t type safe, since it returns a void*' rather than a ptr of the right type (ANSI-C punches a hole in its typing system to make it possible to use malloc() without pointer casting the return value, but C++ closes that hole). Besides,new’ is an operator that can be overridden by a class, while `malloc’ is not overridable on a per-class basis (ie: even if the
class doesn’t have a constructor, allocating via malloc might do inappropriate things if the freestore operations have been overridden).