new()
shouldn't be used as little as possible. It should be used as carefully as possible. And it should be used as often as necessary as dictated by pragmatism.
Allocation of objects on the stack, relying on their implicit destruction, is a simple model. If the required scope of an object fits that model then there's no need to use new()
, with the associated delete()
and checking of NULL pointers.
In the case where you have lots of short-lived objects allocation on the stack should reduce the problems of heap fragmentation.
However, if the lifetime of your object needs to extend beyond the current scope then new()
is the right answer. Just make sure that you pay attention to when and how you call delete()
and the possibilities of NULL pointers, using deleted objects and all of the other gotchas that come with the use of pointers.