Reading through an old C++ Journal I had, I noticed something.
One of the articles asserted that
Foo *f = new Foo();
was nearly unacceptable professional C++ code by and large, and an automatic memory management solution was appropriate.
Is this so?
edit: rephrased: is direct memory management unacceptable for new C++ code, in general? Should auto_ptr(or the other management wrappers) be used for most new code?
This example is very Java like.
In C++ we only use dynamic memory management if it is required.
A better alternative is just to declare a local variable.
If you must use dynamic memory then use a smart pointer.
There are a whole bunch os smart pointers provided int std:: and boost:: (now some are in std::tr1) pick the appropriate one and use it to manage the lifespan of your object.
See Smart Pointers: Or who owns you baby?
Technically you can use new/delete to do memory management.
But in real C++ code it is almost never done. There is nearly always a better alternative to doing memory management by hand.
A simple example is the std::vector. Under the covers it uses new and delete. But you would never be able to tell from the outside. This is completely transparent to the user of the class. All that the user knows is that the vector will take ownership of the object and it will be destroyed when the vector is destroyed.