struct A
{
virtual ~A() { this->f(); }
virtual void f() {};
};
struct B : A
{
int* p;
B() : p(new int) {}
~B()
{
delete p;
p = 0;
}
void f() override { *p = 0; }
};
int main()
{
delete new B; // Is it safe?
}
在虚拟析构函数中调用其他虚拟方法是否安全?