关于子类的析构函数

direction917 direction917 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
class Array{

private :
int * data;
public:
dellocate();
Array(int n){ data = new int[n];}

~Array(){
dellocate();
}
};

Array::dellocate()
{
delete[]data;
}

class Matrix: public Array
{
public:
Matrix(int n)
{
Array::Array(n);
}
dellocate(){
Array::dellocate();
}
~Matrix(){
dellocate();
}
}

测试函数如下:
Matrix ma(10);

这样子写子类的析构函数有问题吗?
为什么程序运行完成后会出现Debug Assertion failure的问题?
请诸位前辈指教啊!

...全文

相关推荐

评论 7
收藏 已收藏
分享
返回顶部
direction917
C++ 语言 65,214 成员 250,514 内容