【c++程序】模拟抽象类
来源:互联网 发布:知乎的timeline 编辑:程序博客网 时间:2024/05/23 16:54
#include<iostream>using namespace std;class Human{public:Human(){cout<<"构造Human"<<endl;}virtual void smart(){}virtual void beautiful(){}virtual ~Human(){cout<<"析构Human"<<endl;}};class father:virtual public Human {public:father(){cout<<"构造father"<<endl;} virtual void smart(){cout<<"父亲很聪明"<<endl;}virtual ~father(){cout<<"析构父亲"<<endl;}};class mother:virtual public Human{public:mother(){cout<<"构造mother"<<endl;}virtual void beautiful(){cout<<"mother is very beautiful!"<<endl;}virtual ~mother(){cout<<"析构mother"<<endl;}};class son:public father,public mother{public:son(){cout<<"构造son"<<endl;}virtual void smart(){cout<<"儿子也很聪明"<<endl;}virtual void beautiful(){cout<<"儿子也很帅"<<endl;}~son (){cout<<"析构儿子"<<endl;}};int main(){Human *p;int choice=0;while(1){bool quit=false;cout<<"0-退出1-父亲2-儿子3-母亲"<<endl;cin>>choice;switch(choice){case 0:quit=true;break;case 1:p=new father;p->beautiful();delete p;break;case 2:p=new son;p->beautiful();p->smart();delete p;break;case 3:p=new mother;p->beautiful();delete p;break;default:cout<<"请输入0-3"<<endl;break;}if(quit){break;}}cout<<"END!!";return 0;}
0 0
- 【c++程序】模拟抽象类
- 模拟抽象类
- 模拟抽象类
- linux c 模拟闹钟程序
- ATM机模拟C程序
- C语言电梯模拟程序
- 抽象类(C++)
- [c++]抽象类
- c+-----------------------------抽象类
- C#_抽象类和抽象方法
- 进程调度---c模拟程序实现
- 汉诺塔搬运模拟程序(C#.net 2003)
- 银行家算法C语言模拟程序
- 一个c#Framework模拟堆栈的程序
- C程序模拟停车场管理问题
- 石头、剪刀、布程序,C语言模拟
- C语言模拟Linux中的cat程序
- 海明码生成模拟程序(c)
- mysqldump: unknown option '--no-beep'
- 裁剪U-boot
- 学习Unity3D之探照灯效果和相机跟随。
- SO Hook 技术汇总 ThomasKing --2014.12.16
- linux c库文件和头文件相关问题
- 【c++程序】模拟抽象类
- C# BeginInvoke和EndInvoke方法操作线程
- 性能测试监控指标
- cocos2d-x中shader的使用
- 谜纸倨钢叭坦姆瘟雌局径垦手既粤酪孔谋倮
- O(1)复杂度的字符串查找算法设计
- 数字滤波器的设计(1)(原理篇)
- Base64加密解密
- 如何在XP系统上搭建 QT 开发平台