求输出结果
#include <iostream>
#include <cstddef>
using namespace std;
class A
{
public:
~A()
{
cout << "A destruct" << endl;
}
};
class B : public A
{
public:
~B()
{
cout << "B destruct" << endl;
}
};
int main()
{
A *pA=new B;
B *pB=new B;
delete pA;
delete pB;
return EXIT_SUCCESS;
}
结果运行截图: