26785-1 继承与派生
来源:互联网 发布:电气预算软件 编辑:程序博客网 时间:2024/05/17 09:40
5-1 继承与派生
#include<iostream>#include<cstring>using namespace std;class Point{public : Point(){x=0;y=0;} Point(float a,float b){x=a;y=b;} float Move (float,float); float Getx(float); float Gety(float); void setting(); void disshow();private: float x,y;};void Point ::setting(){ cin>>x>>y;}float Point::Move(float a,float b){ x+=a; y+=b;}float Point ::Getx(float a){ return x+a;}float Point ::Gety(float b){ return y+b;}void Point ::disshow(){ cout<< x<<" "<<y;}class Rectangle:public Point{public : Rectangle(float a,float b,float c,float d):Point(a,b) { w=c; h=d; } float Geth(); float Getw(); void setting1(); void show();private: float w; float h;};void Rectangle::setting1(){ setting(); cin>>w>>h; if(w<=0) w=0; if(h<=0) h=0;}float Rectangle ::Geth(){ return h;}float Rectangle ::Getw(){ return w;}void Rectangle :: show(){ disshow(); cout<<" "<<w<<" "<<h<<endl;}int main(){ float c,d,a,b; Rectangle r1(a,b,c,d);//注意构造函数的形式 r1.setting1(); cin>>a>>b; r1.Move(a,b); r1.show(); return 0;}
0 0
- 26785-1 继承与派生
- 继承与派生1
- 继承与派生1
- 10-1 派生与继承
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 继承与派生(1)
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- 5-1 继承与派生
- UE4入门与精通
- linux下使用crond定时执行kettle的job任务
- 获取录音文件创建时间及时长
- 面向对象设计原则 面向对象设计原则之迪米特法则
- Android API 24 动画的使用方法
- 26785-1 继承与派生
- golang 操作 系统环境变量小例子
- 查看用户登录信息
- swift3.0 数组的相关知识
- Android移动拼图小游戏
- linux脚本调试-bashdb安装及调试
- DevPartner Studio Professional Edition 11 内存泄露检测使用
- android 状态栏浸透 状态栏半透明
- 学习笔记——SSM框架(eclipse4javaee)spring-framework版本问题