析构函数能是纯虚函数吗?答案是肯定的
#include <iostream>
using namespace std;
class A
{
public:
virtual ~A() = NULL;
};
A::~A() {} //加入该行代码
class B : public A
{
public:
virtual ~B() { cout << "B::~B" << endl; }
};
int main()
{
A * p = new B;
delete p;
B b;
return 0;
}
一切变得不一样了……但实话实说,这样做的意义不大