阅读程序1
来源:互联网 发布:qq群发消息软件 编辑:程序博客网 时间:2024/06/08 12:21
#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;}
运行结果:
心得:
析构函数调用顺序,先调用派生类析构函数,后调用基类构造函数。若不使用虚析构函数,则派生类析构函数将不被调用。
- noip2012 阅读程序1
- 11-阅读程序1
- 阅读程序1
- 阅读程序1
- 12程序阅读1
- 阅读程序1
- 阅读程序(1)
- 程序阅读1
- 阅读程序1、2
- 阅读程序补充-1
- 阅读程序1
- 阅读程序(1)
- 阅读程序1
- 阅读程序(1)
- 阅读程序(1)
- 14-阅读程序1-1
- 16-1阅读程序1
- 第十一周阅读程序1
- selenium webdriver学习(九)------------如何操作cookie
- 论一些网站的倒下
- Android中关于onSaveInstanceState文档
- js日期操作
- Context.getDir
- 阅读程序1
- C语言位操作简析--底层开发程序猿必备
- getCurrnetSession与OpenviewFilter看似矛盾的地方
- HyperMesh二次开发注解【一】---新版本说明
- HDU 1237
- [Win32]客户端程序
- MD5算法分析
- 华为手机 logcat 不出、不完全出日志解决方案
- Java 单例模式详解