孙鑫教程第三章小测试程序
2012-04-15 17:05
253 查看
#include <IOSTREAM.H> //定义一个基类,模拟CWinApp class Base { public: Base(); // virtual void fn();/*测试虚函数结果:call the Derived's fn*/ void fn();/*测试非虚函数结果:call the Base's fn*/ Base *p; }; Base::Base() { p = this;//this指针指向哪一个对象?答:指向派生类对象dd } void Base::fn() { cout << "call the Base's fn" << endl; } //定义一个派生类,模拟CTestApp class Derived:public Base { public: void fn(); }; void Derived::fn() { cout << "call the Derived's fn" << endl; } //定义一个派生类的全局对象,模拟theApp Derived dd; int main() { (dd.p)->fn(); return 0; }
相关文章推荐
- 孙鑫视频教程里第三章的this指针小测试程序
- 孙鑫教程第三章小测试程序
- 关于孙鑫MFC视频第三章中this指针指向基类还是派生类的测试程序
- Lesson1 Windows程序内部运行原理 ---孙鑫VC++教程
- 孙鑫VC视频教程笔记之第九课“程序外观修改及工具栏状态栏编程”
- 孙鑫《vc ++深入详解》第三章mfc框架程序剖析
- MFC视频教程(孙鑫)学习笔记1-Windows程序内部运行原理
- 《JavaScript 基础教程(第6版)》第三章中的Bingo卡片程序实例
- 微信小程序教学第三章(含视频):小程序中级实战教程:列表-页面逻辑处理
- 最全Pycharm教程(9)——创建并运行一个基本的Python测试程序
- Lesson1 Windows程序内部运行原理 ---孙鑫VC++教程
- ROS学习(基于Ubuntu 15.04 和ROS Jade)第三章 ROS核心教程 之 14 测试简单的Service和Client
- 最全Pycharm教程(9)——创建并运行一个基本的Python测试程序 --待整理
- caffe_windows下的第一个测试程序学习教程
- 【Caffe的C++接口使用说明(一)】caffe_windows下的第一个测试程序学习教程
- 最全Pycharm教程(9)——创建并运行一个基本的Python测试程序
- 1_Windows程序运行机制_孙鑫老师VC++教程学习
- SPEC benchmark 测试程序使用教程
- 微信小程序教学第三章(含视频):小程序中级实战教程:列表-页面逻辑处理
- PHPMyWind教程:如何把本地测试好的程序发布到虚拟主机