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

正文內(nèi)容

面向?qū)ο蟪绦蛟O(shè)計(jì)c課后題答案-wenkub.com

2025-06-20 01:29 本頁面
   

【正文】 cout\n data on student 。 coutinput data for teacher 1: 。 score c1。{ cout\n degree: \tdegree。 int eng。{ cout\n english svore: \teng。 stud::print()。 {class score:private student,private stud{ }cout\n score no: \tsno。 char tel[l]。 cout\n telphone no: \ttel。 void print() cout input address: 。 char name[l],id[l]。 coutsetw(8)name。void printname()} cinid。 cinname。 }[5_19]實(shí)現(xiàn)本題功能的程序如下:include include const int l=80。 ()。 office o_ob(4,25,12000,30,8)。main(){//電話數(shù) coutextinguishers39。\n39。 coutsquare footage: footage39。 coutrooms:{ extinguishers=ext。 office(int f,int r,double ft,int p,int ext) public: }private: coutbathroorns: bathrooms39。\n39。\n39。\n39。 void show() bathrooms=bth。 { class house:public building{ //房間數(shù)//層數(shù) floors=f。 cat cat(john)。 }void tiger::whoami(){}。 }{ void whoami()。{ }。virtual void whoami()。 } ()。void main(){}protected: time::display()。 39。 } birthtime(char *,int mm,int dd,int yy,int hh,int mint,int ss) public: { } day=d。 date(int m,int d,int y)class date{ }protected:} seconds=s。 hours=h。 time(int h,int m,int s) public:a39。}。 der_table(int p,int q,char *m):table(p,q)}class der_table:public table{ if((k)%12==0)}。 {public:當(dāng)類SideLine的構(gòu)造函數(shù)調(diào)用了虛基類Person的構(gòu)造函數(shù)之后,類Student和類Employee對(duì)類SideLine的構(gòu)造函數(shù)的調(diào)用被忽略了,這是初始化虛基類和非虛基類不同的地方。 說明:set_price()和print_price()在派生類中是私有成員函數(shù),不能被派生類對(duì)象直接訪問,所以A和D是錯(cuò)誤的。[5_8]答:A[5_9]答:C為了解決這種二義性,C++引入了虛基類的概念。在多個(gè)基類之間則嚴(yán)格按照派生類聲明時(shí)從左到右的順序來排列先后。 }其中基類構(gòu)造函數(shù)的參數(shù),通常來源于派生類構(gòu)造函數(shù)的參數(shù)表,也可以用常數(shù)值。當(dāng)基類含有帶參數(shù)的構(gòu)造函數(shù)時(shí),派生類必須定義構(gòu)造函數(shù),以提供把參數(shù)傳遞給基類構(gòu)造函數(shù)的途徑。因此,為了便于派生類的訪問,可以將基類私有成員中需要提供給派生類訪問的成員定義為保護(hù)成員。 (1)基類中的私有成員無論哪種繼承方式,基類中的私有成員不允許派生類繼承,即在派生類中是不可直接訪問的。 s=+++++。 coutstocks of shanghai are ++endl。//計(jì)算深圳的股票總數(shù) shang_count(shanghai)。//建立對(duì)象 friend void count(const shang_stock ss,const shen_stock zs)。 //PT股票個(gè)數(shù)public: int st。 int general。 general=g。 int pt。 int st。 //深圳類class shang_stock()。}說明:執(zhí)行以下語句,可在定義對(duì)象的同時(shí),給數(shù)據(jù)成員設(shè)置初值。 ()。 ()。 } price=p。 } }[4_19]構(gòu)建一個(gè)類stock 見書139頁 答案如下:include include include const int SIZE=80。 for(i=0。 ob[i].pute()。i6。//測試構(gòu)造函數(shù) total=(long)price*count。 long total。private: void pute()。 count=c。}return 0。 pshow_money()。ob[4]。 book *p。 book ob[5]={ book(1,10),book(2,20), }{ qu=a。 答案見下:include class book{那么對(duì)象anObject是何時(shí)被調(diào)用的呢?是在main()之前,語句”test anObject”處。完成這一工作的方法就是每創(chuàng)建一個(gè)對(duì)象就調(diào)用構(gòu)造函數(shù)一次。 thisx=235。}void main(){或thisx=10。 //錯(cuò)誤,不能對(duì)this直接賦值}。 void use_this()。 } CTest() public: (fri)。}void main(){ //錯(cuò)誤。 =55。 friend void friend_f(CTest fri)。 void use_friend()。 } int i=。}void main(){ i=x。int CTest::readme() const{ //錯(cuò)誤,y1是調(diào)用const定義的,不能修改 const int y2。 public:[4_8]指出下面程序的錯(cuò)誤,并說明原因:答案是將其中對(duì)應(yīng)的2條改成:coutStudent::get_x()”Studet exist,y=”()”\n”。同時(shí)規(guī)定在靜態(tài)成員函數(shù)中不能使用this指針。當(dāng)一個(gè)函數(shù)需要訪問多個(gè)類時(shí),友元函數(shù)非常有用,普通的成員函數(shù)只能訪問其所屬的類,但是多個(gè)類的友元函數(shù)能夠訪問相應(yīng)的所有類的數(shù)據(jù)。每當(dāng)調(diào)用一個(gè)成員函數(shù)時(shí),系統(tǒng)就自動(dòng)把this指針作為一個(gè)隱含的參數(shù)傳給該函數(shù)。第四章:類和對(duì)象(二)[4_1]什么是對(duì)象數(shù)組所謂對(duì)象數(shù)組是指每一數(shù)組元素都是對(duì)象的數(shù)組,也就是說,若一個(gè)類有若干個(gè)對(duì)象,我們把這一系列的對(duì)象用一個(gè)數(shù)組來存放。 } i++,j) char t。 printf(Inverse string: %s\n,str)。 scanf(%s,str)。 char str[100]。開始寫C程序224。C++Source File224。 coutre_strendl。 cout\nreverse string: re_str[i]=39。istrlen(str)。 (str[i])。 for(i=0。 char re_str[20]。 return stck[tos]。 return 0。 { coutStack is empty。}char stack::pop()//彈出棧{ stck[tos]=ch。 { }void stack::push(char ch)//壓入棧{ //棧頂位置(數(shù)組下標(biāo))}。 //將棧頂數(shù)據(jù)彈出棧char pop()。void push(char ch)。{ tos=0。 return 0。 pprint()。 return 1。}void Stock::print(){ strcpy(Stockcode,c)。private: void set(char *c,float pr)。用new自動(dòng)為Stock類的對(duì)象分配內(nèi)存,并將股票代碼“600001”。 }void main(){ volume=*r*r*h。 r=a。private:用類cylinder計(jì)算圓柱體的體積,并存儲(chǔ)在一個(gè)double變量中。 cinday。}date::date(){ month=m。}//解:重載構(gòu)造函數(shù)的實(shí)現(xiàn)如下:date::date(int d,int m,int y){ ()。//構(gòu)造函數(shù)的參數(shù)為3個(gè)整數(shù)/39。 int day,month,year。 public: }void Date::setYear(int y){ ()。 Date testDay。} 習(xí)題:[3_12]根據(jù)注釋語句的提示,實(shí)現(xiàn)類Date的成員函數(shù)include class Date{()。 } { for(int j=0。 }int counter::print()//顯示計(jì)數(shù){ value。 }void counter::increment()//給原值加1{}。 int getvalue()。 ///給原值減1 void increment()。//構(gòu)造函數(shù)例如:將上述語句改成“Stack stt(10)?!笔清e(cuò)誤的,它試圖用私有的構(gòu)造函數(shù)Point訪問公有數(shù)據(jù)成員x和y,這是不對(duì)的。[3_8]答:第1個(gè)錯(cuò)誤:printStu、setSno兩個(gè)成員函數(shù)沒有用public定義,則不允許外部函數(shù)對(duì)對(duì)象進(jìn)行操作。 說明:構(gòu)造函數(shù)的工作是在創(chuàng)建對(duì)象時(shí)執(zhí)行的。但是,不能在類的聲明中給數(shù)據(jù)成員賦初值,數(shù)據(jù)成員的數(shù)據(jù)類型也不能是register(寄存器類型),沒有用private、public、protected定義的數(shù)據(jù)成員是私有成員。說明:C++中對(duì)構(gòu)造函數(shù)有一些規(guī)定:不能帶返回值;可以不帶參數(shù);也可以缺省定義;但構(gòu)造函數(shù)的名字與類名必須完全相同。因此在一個(gè)類中只能有一個(gè)析構(gòu)函數(shù)。(5)構(gòu)造函數(shù)被聲明為公有函數(shù),但它不能象其它成員函數(shù)那樣被顯示地調(diào)用,它是在定義對(duì)象的同時(shí)被調(diào)用的。構(gòu)造函數(shù)具有一些特殊的性質(zhì):(1)構(gòu)造函數(shù)的名字必須與類名相同(2)構(gòu)造函數(shù)可以有任意類型的參數(shù),但不能指定返回類型。 保護(hù)成員函數(shù); 保護(hù)數(shù)據(jù)成員; protected:所以A、B、C是錯(cuò)誤的,D是正確的。 name=new char[5]。[2_19]答:A name=”lin”。修改了常指針,只有D輸出一個(gè)字符是正確的。 [2_17]答:D表示分配10個(gè)整型空間所以運(yùn)行后,a的值被改為10,b的值不變,仍為10[2_16]答:D[2_14]答:運(yùn)行結(jié)果為:101敲進(jìn)兩個(gè)數(shù):10 10 right=middle。 cout”pleass two number:”endl。 }void main(){}cout”sum is “sumendl。 {i=20。 int i,j,sum=0。 } //d是雙精度//敲進(jìn)9 16 25//輸出3 coutx\ty\tzendl。 x=sroot(i)。 cinl。double d,z。double sroot(double)。 610987 1 p++。//p指向第三個(gè)空間for(i=3。 *p=1。 include “”void main(){[2_8]答:使用內(nèi)聯(lián)函數(shù)的優(yōu)點(diǎn)主要有兩個(gè):一是能加快代碼的執(zhí)行,減少調(diào)用開銷;二是能消除宏定義的不安全性。 void main(){ }上面程序的運(yùn)行結(jié)果是14而不是18,但很容易被認(rèn)為是18。 void main
點(diǎn)擊復(fù)制文檔內(nèi)容
研究報(bào)告相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1