第11周程序1
来源:互联网 发布:全球网络连接七彩图 编辑:程序博客网 时间:2024/06/05 04:17
/**Copyright (c) 2013 ,烟台大学计算机学院*All rights reserved.*作者:张凤宁*完成日期:2014年5月7*版本号:v1.0*问题描述:*样例输入:*样例输出:*问题分析:用简单的方法,学会活学活用*/#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
- 第11周程序1
- 第11周项目 程序阅读(1)
- 第11周阅读程序(1)
- 第10、 11 周--阅读程序1
- 第11周项目1阅读程序 静态变量
- 大一第二学期第11周【程序阅读(1)】
- 第11周-程序阅读1-3-多重继承
- 第10、11周-阅读程序(1)
- 第11周阅读程序(5-1)
- 第10、11周阅读程序(1)
- 第10、11周程序阅读 继承和派生 1
- 第10、11周-程序阅读补充(1)
- 第11周项目-阅读程序写结果1
- 第11周上机阅读程序
- 第11周项目-阅读程序
- 第11周项目 程序阅读(2)
- 第11周项目 程序阅读(3)
- 第11周项目 程序阅读(4)
- Android的fill_parent和wrap_content的区别
- 负载均衡
- 记调试MKL MATLAB接口
- 二叉树的java实现与几种遍历
- comparator接口与Comparable接口的区别
- 第11周程序1
- loadFileSystems error & ExceptionUtils错误原因分析
- 高精度之大数乘大数
- Pig源码分析: 简析执行计划的生成
- libjpeg与turbo libjpeg的使用
- android打开文件的工具
- 两个相等的值 经过if 判断后不等于了
- UISplitViewController的实现中遇到的问题
- OpenGL ES From the Ground Up, Part 5: Living in a Material World