Suppose that I have this code - this code does nothing and I understand that their is a memory leak as the destructor of car is not virtual. However I do not understand why I get a debug assertion for this code. I am using visual studio 2010.
struct car {
~car()
{std::cout << "Destructor of car"; }
};
struct honda: public car {
virtual ~honda()
{ std::cout << "Destructor of honda"; }
};
int main()
{
car *c = new honda();
delete c;
}
I do not get this assertion if destructor of honda
class is not declared virtual. I wanted to know what is the issue with that ?