Yes, you have to do that to avoid memory leak. The better ways to do that are to make a vector of shared pointers (boost, C++TR1, C++0x, )
std::vector<std::tr1::shared_ptr<A> > l;
or vector of unique pointers (C++0x) if the objects are not actually shared between this container and something else
std::vector<std::unique_ptr<A>> l;
or use boost pointer containers
boost::ptr_vector<A> l;
PS: Don't forget A's virtual destructor, as per @Neil Butterworth!
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…