This code:
#include <iostream>
class Base { };
class Derived : public Base
{
public:
~Derived()
{
std::cout<< "Derived dtor" << std::endl;
}
};
int main()
{
Derived objD;
objD.~Derived();
return 0;
}
prints:
Derived dtor // destructor called
Derived dtor // printed by 'return 0'
I don't have idea from where comes the second line.
With this main:
int main()
{
Derived objD;
return 0;
}
It prints only one line.