Possible Duplicate:
When to use virtual destructors?
let's say i have an abstract class Animal
class Animal {
public:
Animal(const std::string &name) : _name(name)
{
}
virtual void Print() const = 0;
virtual ~Animal() {}
protected:
std::string _name;
};
and i have Dog and Cat that inherit this class. In a book i'm reading it is recommended to define a virtual destructor in base-class. I tried to create objects without the definition of virtual des' and the program runs fine, without leaks (checked with valgrind). So my question is why use virtual destructor (with empty implementation)? what is the benefit from it?
thank you!