您的位置:首页 > 其它

第13周-程序阅读(2)

2015-06-03 08:03 316 查看
代码:

#include <iostream>
using namespace std;
class BASE
{
private:
char c;
public:
BASE(char n):c(n) {}
virtual ~BASE() { cout<<c; }
};
class DERIVED:public BASE
{
private:
char c;
public:
DERIVED(char n):BASE(n+1),c(n) {}
~DERIVED(){ cout<<c; }
};
int main(){
DERIVED d('X');
return 0;
}


运行结果:

XY
Process returned 0 (0x0)   execution time : 0.016 s
Press any key to continue.


总结:

自动调用相应虚析构函数以释放内存 还是调用该类族所有的析构函数?
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: