- 在线时间
- 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>
- 0 W( T/ N8 r' E# q' U. Q
- using namespace std;4 V8 y: R, D r\\" D1 Z
- class vehicle
- 5 n9 G( K; A9 ]\\" ?4 h& k ~
- {
- 5 t* W' }8 A* [* A9 }
- protected:
- ( z6 X' I& _3 x( M; f
- int wheels;# M) p6 ~' K; K$ F2 E\\" y& E
- double weight;( m0 i- j$ `) B0 E: U# x5 u/ W
- public:
- $ e0 [- w, J: B. h5 I) u5 k5 f
- vehicle(int wh=0,double we=0):wheels(wh),weight(we){}
- 9 s) P3 y5 z5 P& Q' V& R
- int GetWheels(){return wheels;}
- / X7 ?) J9 Q8 c, L7 S N. Q- q
- double GetWeight(){return weight;}
- 9 n# U6 n7 z2 L. \' m1 w: w5 p/ F
- + ?. `) s% o) m
- };9 W% i) N; g2 k& D, J* ]& f. [4 _
- class car:private vehicle4 n+ c\\" o T% `
- {
- 7 I% y- g2 |' l* }
- int passenger_load;
- ) K' @! y Z3 Z
- public:
- 5 F, e5 A7 R8 s( D- }: X; z% h
- car(int wh=0,double we=0,int pa=0):vehicle(wh,we),passenger_load(pa){}9 v3 I( p, _* s2 K+ M! r
- int GetPassenger_load(){return passenger_load;}
- # X$ C7 b. K3 J- W o/ q4 O. y
- int Car_GetWheels(){return GetWheels();}0 T) l' ~: K- X' x
- double Car_GetWeight(){return GetWeight();}
- , O! V2 o5 ~$ R8 _
- };
- 0 ?, @, x i+ m- h& V\\" V
- class truck:private vehicle
- . n! p\\" P3 N4 Y) @
- {
- : ^2 p4 s+ r9 M6 q. N
- int passenger_load;double payload;
- 0 A) O+ }7 C* }' \3 R0 l+ L7 P
- public:4 E6 V! Y& @! [) m0 q+ q5 \: X
- truck(int wh=0,double we=0,int pa=0,double pay=0):vehicle(wh,we),passenger_load(pa),payload(pay){}. k! w, `3 ~. Y& b, C7 i# [ v
- int GetPassenger_load(){return passenger_load;}, m9 ?' @( |: y1 o/ B2 G
- double GetPayload(){return payload;}
- , L2 T( y0 C1 Y0 u/ ^: l
- int Truck_GetWheels(){return GetWheels();}* h3 s4 a/ D$ S
- double Truck_GetWeight(){return GetWeight();}
- # b1 n3 j! q3 H/ K) p: w' S
- };$ s( f, n! M3 m5 G8 L
- int main()% `, J7 B% o/ J/ J' l6 s5 d& d
- {
- & R+ I+ z) t; ~: n. U9 h- Q* a0 B
- vehicle a(4,100);
- 2 b1 P' e. D, v3 v; } \
- cout<<a.GetWheels()<<endl<<a.GetWeight()<<endl;& }$ ?7 c+ S% i
- car b(4,100,6);
- 9 I/ B/ C5 O' L; P' W- T5 g5 D
- cout<<b.Car_GetWheels()<<endl<<b.Car_GetWeight()<<endl<<b.GetPassenger_load()<<endl; R( t/ t% ?3 Q
- truck c(4,100,50,6);& m* z* d& U3 M
- cout<<c.Truck_GetWheels()<<endl<<c.Truck_GetWeight()<<endl<<c.GetPassenger_load()<<endl<<c.GetPayload()<<endl;; y' u! R% _ d+ ^* F( t# U3 F
-
- 6 A) ^) y$ `# i$ J* M7 E
- system("pause");. ]. ~* @/ h! G. j7 G0 @
- return 0;
- - ]: ^* t0 Y4 z) v @9 ]
- }
|
|