64,683
社区成员
发帖
与我相关
我的任务
分享
class Base {
// ...
virtual ~Base();
};
class Derived : public Base {
// ...
~Derived();
};
void f()
{
Base* p = new Derived;
delete p; // virtual destructor used to ensure that ~Derived is called
}
如果不是虚函数,它只会根据指针的类型进行调用。所以说是的