返回信息流#include <iostream>
using namespace std;
class parent
{
public:
parent()
{
cout<<"constructing parent"<<endl;
}
~parent()
{
cout<<"destructing parent "<<endl;
}
virtual void output();
};
void parent::output()
{
cout<<"parent"<<endl;
}
class child : public parent
{
public:
child()
{
cout<<"constructing child"<<endl;
}
~child()
{
cout<<"destructing child "<<endl;
}
virtual void output();
};
void child::output()
{
cout<<"child"<<endl;
}
int main(int argc, char * argv[])
{
parent * p = new child();
delete p ;
}
上面的程序没有调用child的析构函数,如何才能调用呢
这是一条镜像帖。来源:北邮人论坛 / cpp / #77013同步于 2014/2/19
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
[问题]如何才能调用析构函数呢
century
2014/2/19镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。