阅读程序2
来源:互联网 发布:java开发月薪 编辑:程序博客网 时间:2024/05/21 05:55
问题及代码:
/*copyright 计算机与控制工程学院完成日期:2106年5月12日作者:马艳艳文件名称:阅读程序2问题描述:无;输出描述:结果;*/#include<iostream>using namespace std;class A{private: int x;protected: int y;public: int z; A(int a,int b,int c) { x=a; y=b; z=c; } int Getx() {return x; } int Gety() {return y; } void ShowA() { cout<< "x="<<x<<'\t'; cout<<"y="<<y<<'\t'; cout<<"z="<<z<<'\n'; }};class B:public A //修改点(见后面阅读要求){private: int m,n;public: B(int a,int b,int c,int d,int e):A(a,b,c) { m=d; n=e; } void Show(){ cout<<"m="<<m<<'\t'<<"n="<<n<<'\n'; cout<<"x="<<Getx()<<'\t'; cout<<"y="<<y<<'\t'<<"z="<<z<<'\n'; } int Sum() { return (Getx()+y+z+m+n); }};int main(){ B b1(1,2,3,4,5); b1.ShowA(); b1.Show(); cout<< "Sum="<<b1.Sum()<<'\n'; cout<<"x="<<b1.Getx()<<'\t'; cout << "y=" <<b1.Gety()<<'\t'; cout << "z="<<b1.z<<'\n'; return 0;}
运行结果:
0 0
- noip2012 阅读程序2
- 阅读程序(2)
- 11-阅读程序2
- 阅读程序2
- 程序阅读2
- 程序阅读2
- 程序阅读(2)
- 阅读程序1、2
- 补充阅读程序-2
- 阅读程序2
- 阅读程序2
- 阅读程序(2)
- 阅读程序2
- 阅读程序2
- 阅读程序2
- 阅读程序(2)
- 阅读程序(2)
- 阅读程序2
- 《UNIX环境高级编程》(system)
- Java与Oracle中日期转换
- 106_不同状态的页面展示
- 【JDK】:ArrayList和LinkedList源码解析
- 【Java】JSP页面组成
- 阅读程序2
- poj 1823 Hotel
- 工作中用到的sh脚本(持续更新)
- nyoj 311 完全背包
- 107_ListView三个方法的抽取
- UIAutomator入门技巧
- 亿级Web系统搭建——单机到分布式集群
- FZU 2086 Redcarnation
- 遇到问题不会的时候就记下来,因为还有下次。