源程序:
#include <iostream>
using namespace std;
class Bas
{
public:
~Bas()
{
cout << "Bas析构函数" << endl;
}
virtual void f() = 0;
};
class Dev :public Bas
{
public:
~Dev()
{
cout << "Dev析构函数" << endl;
}
virtual void f()
{
cout << "Dev::f" << endl;
}
};
int main()
{
Bas *a;
Dev p;
a = &p;
a->f();
system("pause");
return 1;
}
运行结果: