freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

面向?qū)ο蟪绦蛟O(shè)計(jì)c課后題答案(參考版)

2025-06-26 01:29本頁面
  

【正文】 co。 ()。 ()。 ()。 teacher t1。void main(){ char degree[l],dep[l]。 }private: person::printname()。 void printname() { } cindep。 cout input department: 。 cindegree。 cout input degree: 。 person::input()。 void input() public:}。 int math。 }private: student::printname()。 void printname() { } cineng。 coutinput english score: 。 cinmath。 coutinput math score: 。 stud::input()。 student::input()。 void input() public:}。 int old。 }private: person::printname()。 void printname() cout\n tears old: \told。 { } cinsno。 cout input score no: 。 cinold。 cout input years old: 。 person::input()。 void input() public:}。 char addr[l]。 }private: cintel。 cinaddr。 { void input()}。{ } cout\n certificate no: id。 void print() {class person{ return 0。 cout\noffice: \n。 couthousee: \n。 house h_ob(2,12,5000,6,4)。//滅火器數(shù)}。 int phones。}private:\n39。 couttelephones: phones39。\n39。 rooms39。 coutfloors: floors39。 void show(){ class office:public building{ int bathrooms。//臥室數(shù)\n39。 coutbedrooms: bedrooms39。\n39。 rooms 39。 coutfloors: floors39。 house(int f,int r,double ft,int br,int bth)nbsp。 public://平方數(shù)}。 int floors。 }protected: { building(int f,int r,double ft) public: ()。 ()。//添加的主函數(shù){ couti am atiger name nameendl。 }void cat::whoami(){ coutgeneric animal。 strcpy(name,n)。animal::animal(char *n){void whoami()。 tiger(char *n):cat(n) tiger():cat() public:}。 } cat(char *n):animal(n){class cat:public animal{ char *name。protected: } delete name。 ~animal()animal(char *n)。{}[5_17]程序如下include include class animal{ birthtime yx(yuanxiang ,10,27,1966,13,20,0)。}。 coutchildname39。 void display(){ class birthtime:public time,public date//加此類{ int month,day,year。 }protected: coutmonth/day/year。 year=y。 month=m。 public:}。 couthours:minutes:secondsendl。 virtual void display() {}[5_16]程序編制如下:include include class time{,ASCII valuechar)。,39。 der_table ob(39。 table::ascii()。void der_table::print(void){ void print(void)。 } c=m。 char *c。 protected: cout\n。 } {i++) for(。void table::ascii(void){ void ascii(void)。 } j=q。 i=p。 int i,j。 protected:(2)多重繼承的構(gòu)造函數(shù)執(zhí)行順序遵循先執(zhí)行基類的構(gòu)造函數(shù),再執(zhí)行對(duì)象成員的構(gòu)造函數(shù),最后執(zhí)行派生類構(gòu)造函數(shù)的原則。[5_13]答:運(yùn)行結(jié)果是:Person Name=AngelStudent Name=AngelEmployee Name=AngelSideLine Name=Angel說明:(1)從結(jié)果看出,程序中的虛基類Person的構(gòu)造函數(shù)只執(zhí)行了一次。code是私有數(shù)據(jù)成員,不能直接存取,所以B也是錯(cuò)誤的。 說明:C++中繼承方式有3種:私有繼承、保護(hù)繼承和公有繼承。(3)若同一層次中同時(shí)包含虛基類和非虛基類,應(yīng)先調(diào)用虛基類的構(gòu)造函數(shù),再調(diào)用非虛基類的構(gòu)造函數(shù),最后調(diào)用派生類構(gòu)造函數(shù)。虛基類構(gòu)造函數(shù)的調(diào)用順序是:(1)若同一層次中包含多個(gè)虛基類,這些虛基類的構(gòu)造函數(shù)按它們的說明的先后次序調(diào)用。如果一個(gè)派生類是從多個(gè)基類派生來的,而這些基類又有一個(gè)共同的基類,則在這個(gè)派生類中訪問這個(gè)共同的基類中的成員時(shí),可能會(huì)產(chǎn)生二義性。而析構(gòu)函數(shù)的執(zhí)行順序剛好與構(gòu)造函數(shù)的執(zhí)行順序相反。多繼承構(gòu)造函數(shù)的執(zhí)行順序與單繼承構(gòu)造函數(shù)的執(zhí)行順序相同,也是遵循先執(zhí)行基類的構(gòu)造函數(shù),再執(zhí)行對(duì)象成員的構(gòu)造函數(shù),最后執(zhí)行派生類構(gòu)造函數(shù)的原則。由于析構(gòu)函數(shù)是不帶參數(shù)的,在派生類中是否定義析構(gòu)函數(shù)與它所屬的基類無關(guān),基類的析構(gòu)函數(shù)不會(huì)因?yàn)榕缮悰]有析構(gòu)函數(shù)而得不到執(zhí)行,它們各自是獨(dú)立的。派生類構(gòu)造函數(shù)的一般格式如下:派生類構(gòu)造函數(shù)名(參數(shù)表):基類構(gòu)造函數(shù)名(參數(shù)表){[5_5]答:當(dāng)基類的構(gòu)造函數(shù)沒有參數(shù)或沒有顯示定義構(gòu)造函數(shù)時(shí),派生類可以不向基類傳遞參數(shù),甚至可以不定義構(gòu)造函數(shù)。C++規(guī)定,派生類對(duì)于保護(hù)成員的繼承與公有成員的繼承很相似,也分為兩種情況:若為公有派生,則基類中的保護(hù)成員在派生類中也為保護(hù)成員;若為私有派生,則基類中的保護(hù)成員在派生類中成為私有成員。[5_2]答:派生類不能直接訪問基類的私有成員,但是可以通過基類提供的公有成員函數(shù)間接地訪問基類的私有成員[5_3]答:保護(hù)成員可以被派生類的成員函數(shù)訪問,但是對(duì)于外界是隱藏起來的,外部函數(shù)不能訪問它。當(dāng)類的繼承方式為公有繼承時(shí),基類中的所有公有成員在派生類中仍以公有成員的身份出現(xiàn);當(dāng)類的繼承方式為私有繼承時(shí),基類中的所有公有成員在派生類中都以私有成員的身份出現(xiàn);當(dāng)類的繼承方式為保護(hù)繼承時(shí),基類中的所有公有成員在派生類中都是以保護(hù)成員的身份出現(xiàn)。(2)基類中的公有成員}第五章:繼承與派生類[5_1]答:類的繼承方式有public(公有繼承)、protected(保護(hù)繼承)和private(私有繼承)3種,不同的繼承方式導(dǎo)致原來具有不同訪問屬性的基類成員在派生類中的訪問屬性也有所不同。}void shen_count(const shen_stock es)//計(jì)算深圳的股票總數(shù){ coutstocks of shanghai are ++endl。 return 0。//計(jì)算上海和深圳的股票總數(shù) shen_count(shenzhen)。//計(jì)算上海的股票總數(shù) //建立對(duì)象 shen_stock shenzhen(1500,15,8)。 //表示上海有1600支股票,20支ST股票,10支PT股票 shang_stock shanghai(1600,20,10)。 pt=p。 general=g。 //計(jì)算上海和深圳的股票總數(shù)}。 friend void shen_count(const shen_stock es)。//構(gòu)造函數(shù) int pt。 //ST股票個(gè)數(shù)}class shen_stock{ st=s。shang_stock::shang_stock(int g,int s,int p)//構(gòu)造函數(shù){ int general。 //計(jì)算上海和深圳的股票總數(shù)private: friend void count(const shang_stock ss,const shen_stock zs)。 //股票總數(shù) friend void shang_count(const shang_stock ss)。 //構(gòu)造函數(shù) shang_stock(int g,int s,int p)。定義不含第2和第3個(gè)參數(shù)的對(duì)象st2時(shí),quan的值為1000,price的值 [4_20]編寫一個(gè)有關(guān)股票的程序,見書139頁題include include include class shen_stock。st2=stockc。但構(gòu)造函數(shù)的參數(shù)必須定義為缺省值:stock st2。 return 0。 st2=stockc。 stock st2。 stock st1(600001,3000,)。main(){ float price。 char stockcode[SIZE]。}private: cout thisquan thispriceendl。 coutthisstockcode。 void print(void) quan=q。 stock(char code[],int q=1000,float p=){class stock{ delete ob。 ob[i].print()。i6。// i++) for(int i=0。 ob[5].input(85,65)。 ob[4].input(45,10)。 ob[3].input(25,120)。 ob[2].input(15,20)。 ob[1].input(30,35)。 ob[0].input(25,130)。 ob[0].input(25,130)。 ob=new toy[6]。 toy *ob。 }void main(){ toy te(2,100)。}void toy::pute(){ price=p。}。 int count。 void print()。 void input(int p,int c)。 } { toy(int p,int c) toy(){ } public:}[4_18]使用C++的 p。i++){for(i=0。 p=amp。 int i。*///17題用下面的語句 ob[i].show_money()。i++) for(i=0。 book(3,30),book(4,40),book(5,50) }。main(){ int qu,price。 }private: void show_money() book(int a,int b) public:顯示每個(gè)對(duì)象的q
點(diǎn)擊復(fù)制文檔內(nèi)容
研究報(bào)告相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1