Use dynamically allocated instances of objects when:
1) The actual type of object is not known at compile time
2) When the number of objects you want to create, is not known at compile time
3) When the (compiler generated) lifetime management of your objects does not meet your needs.
Every object created with new operator, should be freed with delete operator at some time. If you don't, you will have memory leaks, and if you depend on the side effects of the objects destructor, you won't get those side effects and your program may not do what it is desired to do.
When an object is created as a stack variable, the compiler will insert code to call the objects destructor when the object goes out of scope. How does the compiler know what destructor to call? The type of object is known at compile time, so there is only one posibility, only one destructor to call.
If you use 'delete' to destroy an object, the compiler may not be able to tell which destructor to use. The object may be of type 'basic', then the destructor 'basic::~basic()' will be called.
class basic;
class derived : public basic
{
....
~derived();
}
basic *l = new derived();
...
delete l;
The compiler does not know the actual type of the object is not 'basic' but 'derived'. If however, you declare the destructor of 'basic' to be virtual, the compiler will insert code that consults the objects virtual method table, and the call is redirected to the right destructor (in this case the destructor that destructs on object of type 'derived').
If you are worried about this problem, and if you can, make the destructor 'virtual'.