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

正文內(nèi)容

最新c面向?qū)ο蟪绦蛟O(shè)計(jì)教程第3版—陳維興林小茶課后習(xí)題答案終稿(編輯修改稿)

2025-07-21 05:15 本頁(yè)面
 

【文章內(nèi)容簡(jiǎn)介】 ass student{private: char name[25], studentNo[10]。 int score。 static int sum。 static int totalScore。public: student(char na[], char stuNo[], int sc)。 void show()。 static void showTotal()。}。student::student(char na[], char stuNo[], int sc){ strcpy(name, na)。 strcpy(studentNo, stuNo)。 score = sc。 ++sum。 totalScore += sc。}void student::show(){ cout 姓名: name endl。 cout 學(xué)號(hào): studentNo endl。 cout 成績(jī): score endl。}void student::showTotal(){ cout 總?cè)藬?shù): sum endl。 cout 平均成績(jī): (double)totalScore/sum endl。}int student::sum = 0。int student::totalScore = 0。int main(){ student s1(張無(wú)忌, 111254, 75)。 student s2(李莫愁, 254114, 60)。 student s3(小龍女, 112587, 88)。 ()。 ()。 ()。 student::showTotal()。return 0。} 有哪幾種繼承方式?每種方式的派生類(lèi)對(duì)基類(lèi)成員的繼承性如何? 公有繼承,私有繼承和保護(hù)繼承。 基類(lèi)的私有成員,無(wú)論哪種繼承方式都不能訪問(wèn)。 公有繼承不改變基類(lèi)的公有和保護(hù)成員的訪問(wèn)限制。 私有繼承將基類(lèi)的公有和保護(hù)成員都變成私有。 保護(hù)繼承將基類(lèi)的公有和保護(hù)成員都變成保護(hù)。 派生類(lèi)能否直接訪問(wèn)基類(lèi)的私有成員?若否,應(yīng)如何實(shí)現(xiàn)? 不能??梢栽诨?lèi)里添加一個(gè)公有成員函數(shù)來(lái)訪問(wèn)私有成員,派生類(lèi)就能繼承這個(gè)公有成員函數(shù),實(shí)現(xiàn)對(duì)基類(lèi)私有成員的訪問(wèn)。 保護(hù)成員有哪些特性?保護(hù)成員以公有方式或私有方式繼承后的訪問(wèn)特性如何? 保護(hù)成員只能被本類(lèi)或本類(lèi)的派生類(lèi)所訪問(wèn),在類(lèi)或派生類(lèi)外是不能被訪問(wèn)的。 后面一問(wèn)見(jiàn)第一題的答案。 派生類(lèi)構(gòu)造函數(shù)和析構(gòu)函數(shù)的執(zhí)行順序是怎樣的? 構(gòu)造函數(shù)是先執(zhí)行父類(lèi)的構(gòu)造函數(shù),再執(zhí)行類(lèi)中其他類(lèi)對(duì)象的構(gòu)造函數(shù),再執(zhí)行本類(lèi)的構(gòu)造函數(shù)。如果同級(jí)有多個(gè)構(gòu)造函數(shù),則按聲明順序執(zhí)行。 析構(gòu)函數(shù)與構(gòu)造函數(shù)的執(zhí)行順序剛好相反。 派生類(lèi)構(gòu)造函數(shù)和析構(gòu)函數(shù)的構(gòu)造規(guī)則是怎樣的? 派生類(lèi)名(參數(shù)總表) : 基類(lèi)名(參數(shù)總表) { 派生類(lèi)新增數(shù)據(jù)成員的初始化語(yǔ)句   }派生類(lèi)中的析構(gòu)函數(shù)與基類(lèi)無(wú)關(guān)。 什么是多繼承?多繼承時(shí),構(gòu)造函數(shù)與析構(gòu)函數(shù)的執(zhí)行順序是怎樣的? 多繼承是指一個(gè)類(lèi)同時(shí)繼承自多個(gè)不同的基類(lèi)。 在類(lèi)的派生中為何要引入虛基類(lèi)?虛基類(lèi)構(gòu)造函數(shù)的調(diào)用順序是如何規(guī)定的? 如果一個(gè)類(lèi)有多個(gè)直接基類(lèi),而這些直接基類(lèi)又有一個(gè)共同的基類(lèi),則在最底層的派生類(lèi)中會(huì)保留這個(gè)簡(jiǎn)介的共同基類(lèi)數(shù)據(jù)成員的多份同名成員。在訪問(wèn)這些同名成員的時(shí)候,會(huì)產(chǎn)生二義性。為了解決二義性,引入了虛基類(lèi)。1) 如果虛基類(lèi)中定義有帶形參的構(gòu)造函數(shù),并且沒(méi)有定義默認(rèn)形式的構(gòu)造函數(shù),則整個(gè)繼承結(jié)構(gòu)中,所有直接或間接的派生類(lèi)都必須在構(gòu)造函數(shù)的成員初始化表中列出對(duì)虛基類(lèi)構(gòu)造函數(shù)的調(diào)用,以初始化在虛基類(lèi)中定義的數(shù)據(jù)成員。2) 建立一個(gè)對(duì)象時(shí),如果這個(gè)對(duì)象中含有從虛基類(lèi)繼承來(lái)的成員,則虛基類(lèi)的成員是由最遠(yuǎn)派生類(lèi)的構(gòu)造函數(shù)通過(guò)調(diào)用虛基類(lèi)的構(gòu)造函數(shù)進(jìn)行初始化的。該派生類(lèi)的其他基類(lèi)對(duì)虛基類(lèi)構(gòu)造函數(shù)的調(diào)用都自動(dòng)被忽略。3) 若同一層次中同時(shí)包含虛基類(lèi)和非虛基類(lèi),應(yīng)先調(diào)用虛基類(lèi)的構(gòu)造函數(shù),再調(diào)用非虛基類(lèi)的構(gòu)造函數(shù),最后調(diào)用派生類(lèi)的構(gòu)造函數(shù)。 ACCB Constructor B1. Constructor B2. Constructor A. 3 2 1 主食=bread 副食=steak 0,0,0 0,1,0 3,6,9 Constructor B1. Constructor B2. Constructor B3. Constructor A. 1 2 4,3 4(1,2)5,6(6,9) class base1 class base2 class level2 class base2 class level1 class toplevelinclude iostreamusing namespace std。include iomanipclass table{public: table(int p, int q) { i = p。 j = q。 } void ascii(void)。protected: int i, j。}。void table::ascii(){ int k = 1。 for(。 i = j。 i++) { cout setw(4) i (char)i。 if((k)%12 == 0) { cout \n。 } k++。 } cout \n。}class der_table:public table{public: der_table(int p, int q, char *m):table(p,q) { c = m。 } void print()。protected: char *c。}。void der_table::print(){ cout c \n。 table::ascii()。}int main(){ der_table ob(39。a39。, 39。z39。, ASCII valuechar)。 ()。 return 0。}include iostreamusing namespace std。include iomanipclass area_c1{protected: double height。 double width。public: area_c1(double r, double s) { height = r。 width = s。 } virtual double area() = 0。}。class rectangle : public area_c1{public: rectangle(double r, double s):area_c1(r, s){} virtual double area()。}。double rectangle::area(){ return height * width。}class isosceles : public area_c1{public: isosceles(double r, double s):area_c1(r, s){} virtual double area()。}。double isosceles::area(){ return (height * width)/2。}int main(){ rectangle r(10, 5)。 isosceles i(4, 6)。 area_c1 *a。 a = amp。r。 cout 矩形的面積是: aarea() endl。 a = amp。i。 cout 三角形的面積是: aarea() endl。 return 0。}include iostreamusing namespace std。include iomanipclass Time{public: Time(int h, int m, int s) { hours = h。 minutes = m。 seconds = s。 } void display() { cout 出生時(shí)間: hours 時(shí) minutes 分 seconds 秒 endl。 }protected: int hours, minutes, seconds。}。class Date{public: Date(int m, int d, int y) { month = m。 day = d。 year = y。 } void display() { cout 出生年月: year 年 month 月 day 日 endl。 }protected: int month, day, year。}。class Birthtime : public Time, public Date{public: Birthtime(char name[], int m, int d, int y, int h, int mi, int s):
點(diǎn)擊復(fù)制文檔內(nèi)容
電大資料相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1