问题描述
为什么在clang ++ 10中不调用派生的析构函数,而在g ++ 9中可以正常工作? 我为什么得到
BC
DC
BD
代替
BC
DC
DD
BD
struct AA
{
AA()
{
cout <<"BC"<<endl;
}
virtual ~AA()
{
cout <<"BD"<<endl;
}
};
struct AB: public AA
{
AB()
{
cout <<"DC"<<endl;
}
~AB() override
{
cout <<"DD"<<endl;
}
};
int main()
{
AA *x= new AB[1];
delete [] x;
return 0;
}
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)