题目信息
-
题目类型
-
练习
-
题目年份
-
2024
-
题目题型
-
问答题
-
关 键 词
-
程序
题目题干
阅读下列程序,写出运行结果。
- # include <iostream>
- # include <string>
- using namespace std;
- class Father
- { protected:
- char Face[20],Eye[20],Mouth[20];
- float High;
- public:
- Father(char *face,char *eye,char *mouth)
- { strcpy(Face,face);
- strcpy(Eye,eye);
- strcpy(Mouth,mouth);
- }
- void Print()
- { cout<<"Father:"<<'\t'<<'\t'<<Face<<'\t'<<Eye<<'\t'<<Mouth<<endl;}
- };
- class Son:public Father
- { private:
- float High;
- public:
- Son(char *face,char *eye,char *mouth,float high):Father(face,eye,mouth)
- { High=high;}
- void Print()
- { cout<<"Son:"<<'\t'<<'\t'<<Face<<'\t'<<Eye<<'\t'<<Mouth<<'\t'<<High<<endl;}
- };
- class Daughter:public Father
- { private:
- float High;
- public:
- Daughter(char *face,char *eye,char *mouth,float high):Father(face,eye,mouth)
- { High=high;}
- void Print()
- { cout<<"Daugther:"<<'\t'<<Face<<'\t'<<Eye<<'\t'<<Mouth<<'\t'<<High<<endl;}
- };
- int main(void)
- { Father ba("square face","big eye","samll mouth");
- Father *pba=&ba;
- pba->Print();
- Son son("square face","big eye","samll mouth",1.75);
- son.Print();
- Daughter daug("square face","big eye","samll mouth",1.60);
- daug.Print();
- return 0;
- }
xCB100150满分答卷(100150.com)-青少年编程等级考试及竞赛题库
答案解析
相关题目
提示声明
- 免责声明:本站资源均来自网络或者用户投稿,仅供用于学习和交流:如有侵权联系删除!
- 温馨提示:本文属于积分文章,需要充值获得积分或升级VIP会员,也可在会员中心投稿获取。
猜你喜欢
Scratch3.0
全国青少年软件编程等级考试
Python
Scratch图形化一级
Scratch图形化四级
Scratch图形化三级
Scratch图形化二级
电子学会