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

正文內(nèi)容

面向?qū)ο蟪绦蛟O(shè)計a卷(編輯修改稿)

2024-10-08 09:03 本頁面
 

【文章內(nèi)容簡介】 、問答題(共 30分) 1. ( 4分)畫出下列程序產(chǎn)生的對象的內(nèi)存映象。 includeiostream includestring using namespace std。 class Member { 得分 評卷人 第 3頁 共 12 頁 int age。 char *name 。 public: Member( int a, char *str) { age = a 。 name = new char[ strlen(str)+1 ]。 strcpy( name, str )。 } void print() { coutnameis age years old.endl。 } }。 int main() { Member obj1( 35, Tom), obj2( 57, Johnson)。 ()。 ()。 return 0。 } 2. ( 4分)閱讀下面程序,寫出運行結(jié)果。 includeiostream using namespace std。 class A { int a,b。 public: A(int x,int y){a=x。b=y。} 第 4頁 共 12 頁 void move(int xx,int yy){ a+=xx 。 b+=yy 。} void print( ){cout(a,b)endl 。} }。 class B : public A { int x , y 。 public: B( int i,int j,int k,int w):A(i,j),x(k),y(w) { } void print( ) { coutx,yendl 。} void f1( ){ move(3,5)。 } void f2( ){ A::print( )。 } }。 int main() 運行結(jié)果: { A a(1,2)。 () 。 B b(3,4,5,6)。 ()。 ::print()。 ::print()。 ()。 return 0。 } 3.( 4分) 已定義了 Demo類的靜態(tài)成員函數(shù) function,該函數(shù)無返回值,無參數(shù)。請分別寫出該函數(shù)在類 中的聲明形式和在類外定義時的函數(shù)頭部,并寫出調(diào)用該函數(shù)的兩種方法 。 1) 在類中的聲明形式: 2) 在類外定義時的函數(shù)頭部: 3)調(diào)用 function函數(shù)的兩種方法 : 第 5頁 共 12 頁 4.( 4 分)什么是虛函數(shù)?虛函數(shù)與函數(shù)重載有哪些相同點與不同點? 5.( 4分)若已定義了 Date 類, myDate為 Date類對象,有如下表達(dá)式 myDate+=60。 ,則 1)將 “+=”運算符重載為成員函數(shù),則其函數(shù)頭為: 2)將 “+=”運算符重載為友員函數(shù),則其函數(shù)頭為: 6.( 4分) 構(gòu)造函數(shù)完成對象初始化的工作,除了普通構(gòu)造函數(shù)外,還可以定義拷貝構(gòu)造函數(shù)和轉(zhuǎn)換構(gòu)造函數(shù),請寫出這兩種構(gòu)造函數(shù)的特點以及在什么情況下會調(diào)用它們。 7.( 2 分)設(shè) GradeBookT類模板有一個名為 getGrade 的成員函數(shù),該函數(shù)的返回值為 T 類型,沒有參數(shù),若在類外定義該函數(shù),請寫出該成員函數(shù)的函數(shù)頭。 8.( 2分)函數(shù)模板與同名的非模板函數(shù)重載時,調(diào)用的順序是怎樣的? 第 6頁 共 12 頁 9.( 2分) 請給出當(dāng)分別以參數(shù) Li Ping, 32和 Li XiaoPing, 24創(chuàng)建對象時下面程序的輸出 。 includeiostream includestring using namespace std。 class Student { char *Name。 int Age。 public: Student(char *name, int age) { int length=strlen(name)。 Name=new char[length+1]。 strcpy(Name,name)。 Age= age。 if(length=0 || length10) throw 0。 if(age30) throw 1。 } }。 int main() { try{ Student(Li Ping,32)。 } catch(int size) { if (size==0) coutName is too longendl。 else coutAge is too oldendl。 } } 1) 當(dāng)對象參數(shù)為 Li Ping,32時程序輸出 : 2) 當(dāng)對象參數(shù)為 Li XiaoPing ,24時程序輸出 : 第 7頁 共 12 頁 三、程序填空題(每空 2分,共 30分) 1.( 18分)閱讀下面程序, 并填空。 該程序的運行結(jié)果為: include iostream include string using namespace std。 class Employee { public: Employee(string na, string de) : { } virtual void print() const。 //輸出職員信息 //析構(gòu)函數(shù) { } private: string name。 //姓名 string dept。 // 部門 }。 //在類外實現(xiàn) print函數(shù) { cout Name: name endl。 cout Dept: dept endl。 } class Manager : //Employee的派生類 { public: Manager(string na, string de, int le) : { } 得分 評卷人 第 8頁 共 12 頁 virtual void print() const //對基類的 print函 數(shù)進(jìn)行重寫 { cout Level: level endl。 } private: int level。 //職別 }。 int main() { //動態(tài)創(chuàng)建姓名為 Sally Smith,部門為 Sales,職別為 2的對象。 Employee* emp = //輸出該對象相關(guān) 信息 return 0。 } 2.( 12分) 以下程序根據(jù)用戶輸入的日期, 從 文件中取出滿足條件的記錄。 文件每 4行存放一條記錄,分別是日期 (day)、時間 (time)、價格 (price)、名稱 (name),如左圖所示,該文件共存放 5條記錄。運行結(jié)果如右圖所示,用戶輸入日期,即可從文件中找到相應(yīng)記錄。 請?zhí)羁铡? 第 9頁 共 12 頁 include iostream include string using namespace std。 void displayEvent( int )。 // display event information int main() { int date。 // event day cout \nSelect date (131) or 0 to exit: 。 cin date。 while ( date != 0 ) { displayEvent( date )。 cout \nSelect date (131) or 0 to exit: 。 cin date。 } cout \n。 return 0。 } 第 10 頁 共 12 頁 void displayEvent( int date ) { string time。 string price。 string name。 string contents。 // line of text from calendarFile int day。 // day of the month for an event // open file for input if ( ) { cout Error: File could not be opened. endl。 exit( 1 )。 } // read
點擊復(fù)制文檔內(nèi)容
環(huán)評公示相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號-1