日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

[YTU]_2575( 交通工具信息)

發布時間:2025/4/16 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [YTU]_2575( 交通工具信息) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

題目描述

有一個交通工具類vehicle,將它為 基類派生的有派生小車類car,卡車類truck和輪船類boat,定義這些類,并使其能夠顯示其各類交通工具的詳細信息。

他們包含的信息,有如下幾種:

1.名字??? -----與輸入的名字相符合

2.時速(km/h)??? -----最高時速

3.耗油量(L/100km) ?? -----在經濟時速下測得耗油量

小車類:
250km/h
14.8 L/100km
卡車類:
140km/h
18L/100km
輪船類:
50km/h
8.33L/100km

輸入

輸入三個派生類對應名字。

輸出

輸出對應類型的信息。

樣例輸入

Mercedes_Benz Transport_truck Boat

樣例輸出

Mercedes_Benz 250km/h 14.8L/100km Transport_truck 140km/h 18L/100km Boat 50km/h 8.33L/100km#include <iostream> using namespace std; class animal {public:animal(int h,int w,char s):height(h),weight(w),sex(s){}virtual void display(){cout<<"height:"<<height<<endl<<"weight:"<<weight<<endl<<"sex:"<<sex<<endl;} protected:int height,weight;char sex; }; class aqu_animal:public animal {public:aqu_animal(int h,int w,char s,int s_p):animal(h,w,s),swimming_speed(s_p){}void display(){cout<<"height:"<<height<<endl<<"weight:"<<weight<<endl<<"sex:"<<sex<<endl<<"swimming_speed:"<<swimming_speed<<endl;}protected:int swimming_speed; }; class ter_animal:public animal { public:ter_animal(int h,int w,char s,int r_p):animal(h,w,s),running_speed(r_p){}void display(){cout<<"height:"<<height<<endl<<"weight:"<<weight<<endl<<"sex:"<<sex<<endl<<"running_speed:"<<running_speed<<endl;} protected:int running_speed; }; int main() {int a,b,s,r;char c;animal *p;cin>>a>>b>>c;animal pa(a,b,c);p=&pa;p->display();cin>>a>>b>>c>>s;aqu_animal pb(a,b,c,s);p=&pb;p->display();cin>>a>>b>>c>>r;ter_animal pc(a,b,c,r);p=&pc;p->display();return 0; }

總結

以上是生活随笔為你收集整理的[YTU]_2575( 交通工具信息)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。