第11周项目1.
来源:互联网 发布:软件咨询合同 编辑:程序博客网 时间:2024/05/18 15:30
#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周项目一
- 第11周-项目1
- 第11周-项目2
- 第11周-项目3
- 第11周项目一
- 第11周项目二
- 第11周项目四
- 第11周项目一
- 第11周项目1.1
- 第11周项目1.2
- 第11周项目7
- 第11周项目4
- 第11周 【项目1
- 第11周 项目1
- 第11周项目1
- 第11周 【项目2
- 第11周项目4
- c++0x_warning.h:31:2: error
- 循环冗余校验(CRC)算法入门引导
- CCNA 精简笔记
- 【项目1 - 存储班长信息的学生类】
- matlab out of memory
- 第11周项目1.
- OllyDBG破解入门教程[图&文]教程
- 算法导论 学习问题
- 储存班长信息的学生类
- tomcat配置ssl,https
- hibernate纯sql查询结果集映射为DTO(VO,DO)
- 奇虎360与腾讯不正当竞争案判决书
- CentOS 6.5 安装私有gitlab环境
- Ironjs