My code looks like this:
#include <iostream>
struct Parent
{
~Parent()
{
std::cout << "parent destructor called" << std::endl;
}
};
struct Child : public Parent
{
int a, b, c;
~Child()
{
std::cout << "child destructor called" << std::endl;
}
};
int main(int argc, char** argv)
{
Parent* p = new Child;
delete p;
return 0;
}
The output is:
parent destructor called
As you can see the destructors are non-virtual. As expected only the parent destructor is called. My child class only has primitive members of type int.
In this case, is it enough if the parent destructor is called? May memory leaks happen? Is it clean CPP?