基类指针delete派生类数组(VC++实现原理)
class A
{
public:
A() {
}
//default A::destructor
private:
...
//members
};
class B : public A
{
public:
B(){}
//default B::destructor
private:
...
//members
};
有如上类定义A B,则delete A指针接收的B数组行为是未定义的:
A* a = new B[2];
delete [.
原创
2022-02-25 14:44:14 ·
726 阅读 ·
0 评论