- 在线时间
- 308 小时
- 最后登录
- 2017-2-18
- 注册时间
- 2011-11-16
- 听众数
- 9
- 收听数
- 0
- 能力
- 0 分
- 体力
- 3942 点
- 威望
- 0 点
- 阅读权限
- 60
- 积分
- 1500
- 相册
- 0
- 日志
- 0
- 记录
- 2
- 帖子
- 632
- 主题
- 29
- 精华
- 0
- 分享
- 0
- 好友
- 94
升级   50% TA的每日心情 | 慵懒 2016-9-24 15:19 |
|---|
签到天数: 412 天 [LV.9]以坛为家II
群组: 学术交流A 群组: 学术交流B 群组: 2013认证赛B题讨论群组 群组: EXCEL |
 - #include<iostream>\\" ]) c$ u! `# [: Z\\" q
- using namespace std;' `$ a& S& m$ Y\\" j, g6 s: t
- class vehicle; }8 R+ I& f, p6 `+ T
- {
- . V8 ^3 {2 s& u# z
- protected:
- & w$ B( ]. P9 W: {9 Q% {
- int wheels;
- - O& @( d. I9 c% l
- double weight;8 k/ d1 B$ d, `5 O
- public:
- / K0 {! `: g3 ?( T: b6 B* L
- vehicle(int wh=0,double we=0):wheels(wh),weight(we){}5 j! S: O6 p. p @# ^% }
- int GetWheels(){return wheels;}
- ; w7 y\\" Z2 w2 F& k3 P
- double GetWeight(){return weight;}
- / a/ q* [% U+ l
- 4 W9 S; f4 u; L( @$ \! K' V$ m+ R
- };
- 9 w$ r* D5 N* R4 t
- class car:private vehicle
- ; N: ?& T G2 E6 [; ?& }) ^3 Y
- {
- 5 ?2 |( y2 {/ y( `
- int passenger_load;( f7 V9 D n6 ~3 r# z6 t
- public:
- ! O: n5 f3 A0 ]. e
- car(int wh=0,double we=0,int pa=0):vehicle(wh,we),passenger_load(pa){}
- * \; f1 O6 U2 ^) ?9 ~% n
- int GetPassenger_load(){return passenger_load;}
- 5 `2 @* ]8 x\\" X: ]
- int Car_GetWheels(){return GetWheels();}
- * B7 `9 A5 |& `# n$ |
- double Car_GetWeight(){return GetWeight();}
- . B+ [* V% C% @\\" Z
- };
- * |\\" u/ l' d\\" O( D ?! ~7 l
- class truck:private vehicle$ [- J, o4 `) q
- {
- 0 @, Q2 C9 v\\" d8 \% m4 a
- int passenger_load;double payload;
- - N1 [5 l0 O4 w3 C: p' u. I
- public:+ N$ X5 n4 K6 y# W; r9 B- G
- truck(int wh=0,double we=0,int pa=0,double pay=0):vehicle(wh,we),passenger_load(pa),payload(pay){}
- 2 }4 C; N1 {1 U! T\\" W# o
- int GetPassenger_load(){return passenger_load;}+ w1 @, f3 ?8 }; V. Z) {0 {) d
- double GetPayload(){return payload;}+ Z5 s4 B/ I8 \: t: W! }7 J
- int Truck_GetWheels(){return GetWheels();} r3 ~- H2 w o& l9 V8 J( }\\" `
- double Truck_GetWeight(){return GetWeight();}
- 8 J$ C0 W; ?8 K9 K2 J% a' T* W( {
- };
- , i+ }' B C( o0 ^2 T* n
- int main()* u& N% t2 c1 J
- {
- 3 g: r2 d$ r4 E' E5 e2 n
- vehicle a(4,100);; f& z. j/ k& {$ J5 X
- cout<<a.GetWheels()<<endl<<a.GetWeight()<<endl;0 ^4 \6 d* D( S1 g. W& e
- car b(4,100,6);
- 3 _8 s& o3 V. \, r
- cout<<b.Car_GetWheels()<<endl<<b.Car_GetWeight()<<endl<<b.GetPassenger_load()<<endl;
- - B6 h8 L% k V* Q' j3 y
- truck c(4,100,50,6);- L\\" @' R- ~6 @- `& q
- cout<<c.Truck_GetWheels()<<endl<<c.Truck_GetWeight()<<endl<<c.GetPassenger_load()<<endl<<c.GetPayload()<<endl;9 O4 s% ]2 s# k- m* j, Z
- # A; Y3 i0 O\\" h8 D# U! h
- system("pause");( h4 S/ o* c# W, L$ R% J
- return 0;. g9 {8 Y7 N& P g
- }
|
|