- 在线时间
- 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># Y& f2 N1 ~. i- l$ z
- using namespace std;/ g0 N: ^; b# ~/ u/ a! \) ?
- class vehicle
- : u) t- \' H9 x* C. m; v
- {
- % Y8 U\\" B- Z\\" ], _ W$ a
- protected:
- 0 f4 C. R* x5 i, x\\" ?0 J: i
- int wheels;
- \\" ^1 P5 Y' k$ {$ L, s! o( g
- double weight;
- / W2 o1 |\\" X1 [% r0 [; d/ g. }4 K. c
- public:
- 7 K# {9 j0 \- n+ |% j: C2 Z* u( Z
- vehicle(int wh=0,double we=0):wheels(wh),weight(we){}
- 3 X( a5 [* P0 D* A6 m2 N/ G
- int GetWheels(){return wheels;}
- & C: r7 K+ L$ G+ C5 q
- double GetWeight(){return weight;}3 L) o( w, q. o- e. l& o; e
-
- & x8 q\\" j& m* | k3 }8 z$ ]
- };. b7 q3 ^; {9 }\\" T5 Z
- class car:private vehicle\\" v: b1 ]; @6 Q8 ]
- {
- 9 J7 ~; k* c( a. T; q$ g! p
- int passenger_load;
- 4 I# d+ N \2 C7 x2 A
- public:
- / q\\" T4 [) H6 A u: [
- car(int wh=0,double we=0,int pa=0):vehicle(wh,we),passenger_load(pa){}
- * [, U9 r) F6 j- \0 V# ^
- int GetPassenger_load(){return passenger_load;}
- 6 d$ r3 S9 b5 \6 Q& A+ c
- int Car_GetWheels(){return GetWheels();}
- 8 l$ l2 ?8 x1 ~9 s$ j
- double Car_GetWeight(){return GetWeight();}
- ! l, c8 E' A# r. d( @$ c3 K
- };
- ) ]* J0 G7 o0 m/ J
- class truck:private vehicle9 a6 E/ s0 U# |% {
- {
- ; V& i4 m0 A @4 a
- int passenger_load;double payload;4 J$ t% l) y/ P' {- y5 T: N
- public:
- 4 I7 N1 r\\" F3 I9 K
- truck(int wh=0,double we=0,int pa=0,double pay=0):vehicle(wh,we),passenger_load(pa),payload(pay){}) E5 f3 \: @4 W
- int GetPassenger_load(){return passenger_load;}: ^- V\\" B- S- A9 n1 o
- double GetPayload(){return payload;}) D9 w1 @7 n& Q5 [$ g
- int Truck_GetWheels(){return GetWheels();}
- ; U* S: B\\" M( K; S) E1 V
- double Truck_GetWeight(){return GetWeight();}
- ( P& ^+ }2 L7 C4 N6 x/ V
- };. u6 [3 f& B, J& r' i# T. ^' b
- int main()
- 7 N9 M! v1 T! v r# N0 {$ W1 E
- {) F\\" q$ P* T) F0 }; r+ S0 |* v
- vehicle a(4,100);! T( f\\" E2 `% s) y$ g! s/ Q F9 S0 ]
- cout<<a.GetWheels()<<endl<<a.GetWeight()<<endl;4 c! q8 \8 P! G3 x
- car b(4,100,6);7 i( X2 U5 Z( L0 R2 n4 n( o
- cout<<b.Car_GetWheels()<<endl<<b.Car_GetWeight()<<endl<<b.GetPassenger_load()<<endl;
- 7 A, g2 U% u6 o: s6 g* J! Z; @
- truck c(4,100,50,6);
- ) |% v) n. C( E2 h, ?
- cout<<c.Truck_GetWheels()<<endl<<c.Truck_GetWeight()<<endl<<c.GetPassenger_load()<<endl<<c.GetPayload()<<endl;9 r1 o\\" H% i: f# A5 j
-
- 6 {5 c7 r5 o8 T( W- m: T
- system("pause");
- 3 f! p/ a3 T5 T( s
- return 0;
- $ d9 L) j/ [4 m
- }
|
|