This is the best I can come up with. The base class destructor is overridden by the default destructor, which destructs each member and then calls the base class destructor.
You can also override the base class destructor in derived yourself, which would be obvious. The only strange thing is that the calling of the base class destructor at the end of the derived class destructor is automatic.
Code:
#include <iostream>
class base
{
public:
virtual ~base() { std::cout << "In base destructor.\n"; }
};
class member
{
public:
~member() { std::cout << "In member destructor.\n"; }
};
class derived : public base
{
member m;
};
int main()
{
{
derived d;
}
}