08092面向?qū)ο蟪绦蛟O(shè)計(jì)雙語卷答案計(jì)科081_第1頁
08092面向?qū)ο蟪绦蛟O(shè)計(jì)雙語卷答案計(jì)科081_第2頁
08092面向?qū)ο蟪绦蛟O(shè)計(jì)雙語卷答案計(jì)科081_第3頁
08092面向?qū)ο蟪绦蛟O(shè)計(jì)雙語卷答案計(jì)科081_第4頁
08092面向?qū)ο蟪绦蛟O(shè)計(jì)雙語卷答案計(jì)科081_第5頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、2008 年2009 年第二學(xué)期面象程序設(shè)計(jì)(雙語)期末試題C 卷計(jì)科 081-2 班一、Describe conceptions and give exles (每小題 10 分,共 20 分)1. Describe the definition of Friend function (友員函數(shù)). Please give an exle.Answer: Friend functions are not members of a class, b variables of the class(此處給出正確定義得 5 分)an acs private memberFor Exle:class

2、DayofYear public:friend bool equal(DayofYear date1, DayofYear date2); /友員函數(shù)DayofYear (); private:month; day;/友員函數(shù)的實(shí)現(xiàn)bool equal(DayofYear date1, DayofYear date2) return(date1.month= =date2.month&date1.day= =date2.day);(給出正確的實(shí)例得 5 分)2. Describe the definition of Dynamic Variables (動(dòng)態(tài)變量). Please givean

3、exle to create a dynamic variable of typeAnswer: new operator can create variables.ve no identifiers to serve as theirnames; the variables are called dynamic variables. (此處給出正確定義得 5 分)For Exle:*p;p= new;(給出正確的實(shí)例得 5 分)二、Rerograms, and give the results (每小題 10 分,共 30 分)1. What is the output produced b

4、y the followinAnswer:oHow are you?o lines.2. What is the output produced by the following program.Answer:Try block entered. Exception thrown with wait_time equal to 46 After catch block.3. Consider the following code:Answer: ab三、Programming (每小題 10 分,共 50 分)1. Write a complete( 完整) C+ program messag

5、e on the screen.Answer:#include t output( 輸出)the followingusing namespamain( )td;double n1=1.0,n2=2.0;coute! endl;coutn1tn1endl; coutn2tn2n2)return n1; elsereturn n2;double max(double n1, double n2, double n3) double m;if(n1n2) m=n1;elsem=n2; if(n3m) m=n3; return m;3. Write a programt input some num

6、bers of typefrom keyboard(鍵盤)and output the numbers to a file “outfile.dat”.Answer: #include #include #include #includeusing namespa main() next;td;ofstream outfile; outfile.open(outfile.dat); if(outfile.fail()coutthe open file is failed!next) outfilenextendl;outfile.close(); return 0;4. According t

7、o the following test program, define and implement a class which can use the following program to test it.Answer:class Employee public:Employee ();Employee (string name, void show();private:string emp_name; data1;data2;string emp_depart;n1,n2, string depart);Employee: Employee():emp_name(“”),data1(0

8、),data2(0),emp_depart(“”) Employee: Employee(string name, emp_name=name;data1=n1; data2=n2; emp_depart=depart;void Employee:show()n1,n2, string depart)cout”the employees name is emp_nameendl”the employees data1 is data1endl”the employees data2 is data2endl”the employees department is departendl;5. T

9、here is a base class Student as follows:Answer:#include #includeusing namespatd;class Computer_stu:public Studentpublic:Computer_stu();Computer_stu(string no,string name,string depart1,double score1); void show_infor();private:string depart; double score;Computer_stu: Computer_stu():Student()depart=; score=0;puter_stu(string score1):Student(no,name)depart=depart1; score=score1;void Computer_stu:show_infor()no,stringname,stringdepart1,doublecoutthe students number is:stu_noendlthe students name is:stu_nameendlthe students depart is:departendlthe

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論