024 这是什么鬼delete

#include <iostream> 
using namespace std;
class A
{
public:
    A() { }

    // 在此处补充你的代码
    virtual ~A() { cout << "destructor A" << endl; }

};
class B :public A {
public:
    ~B() { cout << "destructor B" << endl; }
};
int main()
{
    A* pa;
    pa = new B;
    delete pa;
    return 0;
}


posted @ 2022-02-22 10:57  icefield817  阅读(68)  评论(0编辑  收藏  举报