2015年電大面向對象程序設計C++考試復習題資料小抄_第1頁
2015年電大面向對象程序設計C++考試復習題資料小抄_第2頁
2015年電大面向對象程序設計C++考試復習題資料小抄_第3頁
2015年電大面向對象程序設計C++考試復習題資料小抄_第4頁
2015年電大面向對象程序設計C++考試復習題資料小抄_第5頁
已閱讀5頁,還剩4頁未讀 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

一、選擇題 1、重載函數在調用時選擇的依據中 ,錯誤的是 A參數個數 B參數類型 C函數名字 D.函數類型 2、有關構造函數的說法不正確的是 A.構造函數名字和類的名字一樣 B.構造函數在說明變量時自動執(zhí)行 C.構造函數無任何函數類型 D.構造函數有且只有一個 3、下列關于 C+函數的敘述中,正確的是 ( )。 A)每個函數至少要具有一個參數 B)每個函數都必須返回一個值 C)函數在被調用之前必須先聲明 D)函數不能自己調用自己 4、下列關于類和對象的敘述中,錯誤的是 ( )。 A)一個類只能有一個對象 B)對象是類的具體實例 C)類是對某一類對象的抽象 D)類和對象的關系是一種數據類型與變量的關系 5、在 C+中,用于實現運行時多態(tài)性的是 ( )。 A)內聯函數 B)重載函數 C)模板函數 D)虛函數 6、下列關于運算符重載的敘述中,正確的是 ( )。 A)通過運算符重載,可以定義新的運算符 B)有的運算符只能作為成員函數重載 C)若重載運算符 +,則相應的運算符函數名是 + D)重載二元運算符時,必須聲明兩個形參 7、對于語句 coutxendl;錯誤的是描述是 ( )。 A)“cout” 是一個輸出流對象 B)“endl” 的作用是輸出回車換行 C)“x” 是一個變量 D)“” 稱作提取運算符 8、有如下類聲明,則類 MyDERIVED 中保護的數據成員和成員函數的個數是 ( )。 class MyBASE private: int k; public: void set(int n) k=n; int get( )const return k; ; class MyDERIVED: protected MyBASE protected: int j; public: void set(int m, int n) MyBASE:set(m); j=n; int get( ) const return MyBASE:get( )+j; ; A)4 B)3 C)2 D)1 9、下列關于派生類構造函數的描述中,錯誤的是 A派生類構造函數應包含直接基類和所有間接基類的構造函數 B派生類構造函數僅包含直接基類構造函數和其他(如子對象)類構造函數等 C派生類構造函數通常帶有成員初始化表 D派生類默認構造函數中隱含包括直接基類的默認構造函數 10、已知在一個類體中包含如下函數原型 : Volume operator-(Volume)const;, 下列關于這個函數的敘述中 , 錯誤的是 ( )。 A)這是運算符 -的重載運算符函數 B)這個函數所重載的運算符 是一個一元運算符 C)這是一個成員函數 D)這個函數不改變類的任何數據成員的值 11、執(zhí)行如下的程序段后,輸出結果是 ( )。 cout.fill(*); cout.width(6); cout.fill(#); cout 123 endl; A)#123 B)123# C)*123 D)123* 12、在下列函數原型中 , 可以作為類 AA構造函數的是 ( )。 A)void AA(int); B)int AA(); C)AA(int)const; D)AA(int); 13、下面四個選項中, ( )是用來聲明虛函數的。 A)virtual B)public C)include D)using namespace 14、實現運行時的多態(tài)性要使用 ( )。 A)重載函數 B)構造函數 C)析構函數 D)虛函數 15、要實現動態(tài)聯編,必須通過 ( )調用虛函數。 A)對象指針 B)成員名限定 C)對象名 D)派生類名 16、以下 ( )成員函數表 示純虛函數。 A)virtual int vf(int); B)void vf(int)=0; C)virtual void vf()=0; D)virtual void vf(int) 17、在每個 C+程序中都必須包含有這樣一個函數,該函數的函數名為 。 A. main B. MAIN C. name D. function 18、設 x和 y均為 bool量,則 x&y為真的條件是 。 A. 它們均為真 B. 其中一個為真 C. 它們均為假 D. 其中一個為假 19、下面的哪個保留字不能作為函數的返回類型? 。 A. void B. int C. new D. long 20、假定 a為一個整型數組名,則元素 a4的字節(jié)地址為 。 A. a+4 B. a+8 C. a+16 D. a+32 21、假定 AB為一個類,則執(zhí)行 “AB a(4) , b3 , * p2 ;” 語句時,自動調用該類構造函數的次數為 。 A. 3 B. 4 C. 6 D. 9 22、 假定要對類 AB定義加號操作符重載成員函數,實現兩個 AB類對象的加法,并返回相加結果,則該成員函數的聲明語句為: 。 A. AB operator+(AB & a , AB & b) B. AB operator+(AB & a) C. operator+(AB a) D. AB & operator+( ) 23、有如下類聲明 : class XA private: int x; public: XA(int n) x=n; ; class XB: public XA private: int y; public: XB(int a,int b); ; 在構造函數 XB的下列定義中,正確的是 ( )。 A)XB:XB(int a,int b): x(a),y(b) B)XB:XB(int a,int b): XA(a),y(b) C)XB:XB(int a,int b): x(a),XB(b) D)XB:XB(int a,int b): XA(a),XB(b) 24、在表達式 x+y*z中, + 是作為成員函數重載的運算符, * 是作為非成員函數重載的運算符。則 operator+ 有 個參數, operator* 有 參數。 ( ) A)2、 2 B)2、 1 C)1、 2 D)1、 1 25、應在下列程序劃線處填入的正確語句是 ( )。 class Base public: void fun()coutBase:funendl; ; class Derived:public Base void fun() /顯示調用基類的函數 fun() coutDerived:funfun(); 26、下列關于繼承的描述中,正確的是 A.繼承不是類之間的一種關系 B.C+語言僅支持單一繼承 C.繼承會增加程序的冗余性 D.繼承是面向對象方法中一個很重要的特性 27、在 int b3=1,3,2,4,5,6,0中 ,a22的值是 A. 0 B. 5 C.6 D.2 28、下列給字符數組進行的初始化中 ,正確的是 A. char s1=abcd; B.char s23=xyz; C. char s3=a,x,y; D.char s423=xyz,mnp; 29、已知 : int a,&ra=a;關于 ra的描述中正確的是 A. ra 是 int型變量 a的地址值 B.a是 int型變量 ra的地址值 C. ra 是 int型變量 a的引用 D. ra 是 int型變量 a的指針 30、對于 int *pa5;的描述 ,正確的是 A. pa 是一個指向數組的指針 ,所指向的數組是 5個 int型元素 B. pa 是一個指向某數組中第 5 個元素的指針 ,該元素是 int型變量 C. pa5表示某個數組中的第 5個元素的值 D. pa 是一個具有 5個元素的指針數組 ,每個元素是一個 int型指針 31、有關類的說法不正確的是 A類是一種用戶自定義的數據類型 B. 類中的成員函數可 以存取類中的私有數據 C. 在類中,如果不作特別說明,所有的數據均為私有類型 D. 在類中,如果不作特別說明,所有的成員函數均為公有類型 32、 C+語言中規(guī)定函數的返回值的類型是由 A return 語句中的表達式類型所決定 B 調用該函數時的主調用函數類型所決 C 調用該函數時系統(tǒng)臨時決定 D 在定義該函數時所指定的函數類型所決定 33、有一個 int類型變量 ,在程序中頻繁使用 ,最好定義它為 A register B auto C extern D static 34、如果 a=1,b=2,c=3,d=4,則條件表達式 ab?a:cd?c:d 的值為 A 1 B 2 C 3 D 4 35、下列運算符中,在 C+中不能重載運算符是 A?: B + C - D = 36、如果一個類至少有一個純虛函數,那么就稱該類為 A抽象類 B虛基類 C派生類 D以上都不對 37、在下列關鍵字中,用以說明類中公有成員的是 A public B private C protected D friend 38、要求通過函數來實現一種不太復雜的功能 ,并且要求加快執(zhí)行速度 ,選用 A內聯函數 B重載函數 C遞歸調用 D嵌套調用 39、功能為對對象進行初始化的是 A析構函數 B數據成員 C構造函數 D靜態(tài)成員函數 40、下述靜態(tài)數據成員的特性中,錯誤的是 A說明靜態(tài)數據成員時前邊要加修飾符 static B靜態(tài)數據成員要在類體外進行初始化 C引用靜態(tài)數據成員時,要在靜態(tài)數據成員前加類名和作用域運算符 D靜態(tài)數據成員不是所有對象所共有的 41、在 C+中 ,關于下列設置參數默認值的描述中 ,正確的是 A不允許設置參數的默認值 B設置參數默認值只能在定義函數時設置 C設置參數默認值 時 ,應該是先設置右邊的再設置左邊的 D設置參數默認值時 ,應該全部參數都設置 42、 print()函數是一個類的常成員函數 ,它無返回值 ,下列表示中 ,正確的是 A void print() const B const void print() C void const print() D void print(const) 二、填空題 1、面向對象程序設計有四個主要特點,即抽象、封裝、 _和 _。 2、非成員函數應聲明為類的 _函數才能訪問這個類的 private成員。 3、派生類中的成員 不能直接訪問基類中的 _成員。 4、在用 class定義一個類時,數據成員和成員函數的默認訪問權限是 _。 5、運算符重載函數可能是類的 _函數,也可以是類的 _函數,還可以是普通函數。 6、用流對象的成員函數控制輸出格式時,用于設置字段寬度的流成員函數的名稱是 _,與之作用相同的控制符名稱是 _。 7、含有純虛函數的類稱為 _。 8、使用 cin和 cout進行輸入輸出操作的程序必須包含頭文件 _ ,其語句格式為 _ 。 9、 C+語言中使用 const定義常量時需要指出 _ 、 _ 和 _ 。 10、派生類的構造函數的初始化表中,通常應包含 _ 構造函數和 _ 構造函數。 11、 C+語言支持兩種多態(tài)性,分別是 _ 和 _ 。 12、函數調用 excc(v1,v2),(v3,v4,v5),v6);語句中實參的個數是 _ 。 13、 C+語言中的每條基本語句以 作為結束符,每條復合語句以 作為結束符。 14、執(zhí)行 “cout char(A+2)5的相反表達式為 。 18、假定一個一維數組的定義為 “char * a8 ;” ,則該數組所含元素的個數為 ,所占存儲空間的字節(jié)數為 。 19、變量分為全局和局部兩種, 變量沒有賦初值時,其值是不確定的。 20、假定 a是一個二維數組,則 aij的指針訪問方式為 。 21、假定一個結構類型定義為 “struct D int a ; union int b ; double c ; ; D * d2 ; ;” , 則該類型的大小為 字節(jié)。 22、對一個類中的數據成員的初始化可以通過構造函 數中的 實現,也可以通過構造函數中的 實現。 23、假定 AB為一個類,則執(zhí)行 “AB a10;” 語句時,系統(tǒng)自動調用該類的構造函數的次數為 。 242、假定類 AB中有一個公用屬性的靜態(tài)數據成員 bb,在類外不通過對象名訪問該成員 bb的寫法為 。 三、程序的填空、程序的執(zhí)行 1、以下程序是定義一個計數器類counter,對 其重載運算符 “+”,請?zhí)羁铡?class counter private: int n; public: counter() n=0; counter(int i)n=i; _ /運算符重載函數 counter t; t.n=n+c.n; return t; void disp() coutn=nendl; ; void main() counter c1(5),c2(10),c3; c3=c1+c2; c1.disp(); c2.disp(); c3.disp(); 2、下列程序的輸出結果為 2,請將程序補充完整。 class Base public: _ void fun() cout1; ; class Derived: public Base public: void fun( ) coutfun( ); delete p; return 0; 3、寫出執(zhí)行下面程序的輸出結果。 void fun(int &x, int y) int t=x; x=y; y=t; int main( ) int a2 = 23, 42; fun(a1,a0); std:couta0,a1std:endl; return 0; 27、寫出執(zhí)行下面程序的輸出結果。 class A public: A() coutA; ; class B public: B() coutB; ; class C : public A B b; public: C() coutC; ; int main( ) C obj; return 0; 4、寫出執(zhí)行下面程序的輸出結果。 class Base private: char c; public: Base(char n):c(n) virtual Base()coutC; ; class Der:public Base private: char c; public: Der(char n):Base(n+1),c(n) Der()coutC; ; int main() Der(X); return 0; 5. #include void fun(int *s,int n1,int n2) int i,j,t; i=n1;j=n2; while (ij) t=*(s+i); *(s+i)=*(s+j); *(s+j)=t; i+; j-; void main() int a10=1,2,3,4,5,6,7,8,9,0,i,*p=a; 輸出結果為: fun(p,0,3);fun (p,4,9);fun(p,0,9); for (i=0;i10;i+) cout *(a+i); cout endl; 6. 有如下程序 #include #include class Girl char *name , *dial; public: Girl(char *n, char *d) name=new charstrlen(n)+1; strcpy(name, n); dial= new charstrlen(d)+1; strcpy(dial,d); friend void disp(Girl &); Girl() delete name; delete dial; ; void disp(Girl &x) cout”Girl s name is:””,tel:”x.dialendl; void main() Girl e(“Liping”,); disp(e); 其輸出結果為: 程序中突出介紹了 C+中用于對私有成員訪問的什么概念。 7. #include class base public: virtual void who() coutbase classendl; ; class derive1:public base public: void who() coutderivel class endl; ; class derive2:public base public: void who() coutderive2 class who(); p=&obj2; p-who(); p=&obj3; p-who(); 四、編程題 1、 編寫一個程序,設計一個滿足如下要求的 Cdate類: 用下面的格式輸出日期: 日 /月 /年; 輸出在當前日期上加一天后的日期; 設 置日期。 2、編寫一個程序設計一個棧操作類,包含入棧和出棧成員函數,然后入棧一組數據,出棧并顯示出棧順序。 3、編寫一個程序計算 “ 三角形、正方形、圓形 ” 三種圖形的面積,要求: a)抽象出一個基類 base; b)在其中說明一個虛函數用來求面積; c)利用派生類定義 “ 三角形、正方形、圓形 ” ; d)編寫主函數。 4、 編寫程序,把從鍵盤上輸入的一批整數 (以 -1 作為終止輸入的標志 )保存到文本文件“a:xxk1.dat” 中。 請您刪除一下內容, O( _ )O 謝謝! 2015 年中央電大期末復習考試小抄大全,電大期末考試必備小抄,電大考試必過小抄 After earning his spurs in the kitchens of The Westin, The Sheraton, Sens on the Bund, and a sprinkling of other top-notch venues, Simpson Lu fi nally got the chance to become his own boss in November 2010. Sort of. The Shanghai-born chef might not actually own California Pizza Kitchen (CPK) but he is in sole charge of both kitchen and frontof- house at this Sinan Mansionsstalwart. Its certainly a responsibility to be the head chef, and then to have to manage the rest of the restaurant as well, the 31-year-old tells Enjoy Shanghai. In hotels, for example, these jobs are strictly demarcated, so its a great opportunity to learn how a business operates across the board. It was a task that management back in sunny California evidently felt he was ready for, and a vote of confi dence from a company that, to date, has opened 250 outlets in 11 countries. And for added pressure, the Shanghai branch was also CPKs China debut. For sure it was a big step, and unlike all their other Asia operations that are franchises, they decided to manage it directly to begin with, says Simpson. Two years ago a private franchisee took over the lease, but the links to CPK headquarters are still strong, with a mainland-based brand ambassador on hand to ensure the business adheres to its ethos of creating innovative, hearth-baked pizzas, a slice of PR blurb that Simpson insists lives up to the hype. They are very innovative, he says. The problem with most fast food places is that they use the same sauce on every pizza and just change the toppings. Every one of our 16 pizza sauces is a unique recipe that has been formulated to complement the toppings perfectly. The largely local customer base evidently agrees and on Saturday and Sunday, at least, the place is teeming. The kids-eat-for-free policy at weekends is undoubtedly a big draw, as well as is the spacious second-fl oor layout overlooked by a canopy of green from Fuxing Park over the road. The company is also focusing on increasing brand recognition and in recent years has taken part in outside events such as the regular California Week. Still, the sta are honest enough to admit that business could be better; as good, in fact, as in CPKs second outlet in the popular Kerry Parkside shopping mall in Pudong. Sinan Mansions has really struggled to get the number of visitors that were envisaged when it first opened, and it hasnt been easy for any of the tenants here, adds Simpson. Were planning a third outlet in the city in 2015, and we will probably choose a shopping mall again because of the better foot traffic. The tearooms once frequented by Coco Chanel and Marcel Proust are upping sticks and coming to Shanghai, Xu Junqian visits the Parisian outpost with sweet treats. One thing the century-old Parisian tearoom Angelina has shown is that legendary fashion designer Coco Chanel not only had style and glamor but also boasted great taste in food, pastries in particular. One of the most popular tearooms in Paris, Angelina is famous for having once been frequented by celebrities such as Chanel and writer Marcel Proust. Now Angelina has packed up its French ambience, efficient service, and beautiful, comforting desserts and flown them to Shanghai. At the flagship dine-in and take-out space in Shanghai, everything mimics the original tearoom designed from the beginning of the 20th century, in Paris, the height of Belle Epoque. The paintings on the wall, for example, are exactly the same as the one that depicts the landscape of southern France, the hometown of the owner; and the small tables are intentional imitations of the ones that Coco Chanel once sat at every afternoon for hot chocolate. The famous hot chocolate, known as LAfricain, is a luxurious mixture of four types of cocoa beans imported from Africa, blended in Paris and then shipped to Shanghai. Its sinfully sweet, rich and thick as if putting a bar of melting chocolate directly on the tongue and the fresh whipped cream on the side makes a light, but equally gratifying contrast. It is also sold in glass bottles as takeaway. The signature Mont-Blanc chestnut cake consists of three parts: the pureed chestnut on top, the vanilla cream like stuffing, and the meringue as base. Get all three layers in one scoop, not only for the different textures but also various flavors of sweetness. The dessert has maintained its popularity for a century, even in a country like France, perhaps the worlds most competitive place for desserts. A much overlooked pairing, is the Paris-New York choux pastry and N226 chocolate flavored tea. The choux pastry is a mouthful of airy pecan-flavored whipped cream, while the tea, a blend of black teas from China and Ceylon, cocoa and rose petals, offers a more subtle fragrance of flowers and chocolate. Ordering these two items, featuring a muted sweetness, makes it easier for you to fit into your little black dress. Breakfast, brunch, lunch and light supper are also served at the tearoom, a hub of many cultures and takes in a mix of different styles of French cuisines, according to the management team. The semi-cooked foie gras terrine, is seductive and deceptive. Its generously served at the size and shape of a toast, while the actual brioche toast is baked into a curved slice dipped with fig chutney. The flavor, however, is honest: strong, smooth and sublime. And you dont actually need the toast for crunchiness. This is the season for high teas, with dainty cups of fine china and little pastries that appeal to both visual and physical appetites. But there is one high tea with a difference, and Pauline D. Loh finds out just exactly why it is special. Earl Grey tea and macarons are all very well for the crucial recuperative break in-between intensive bouts of holiday season shopping. And for those who prefer savory to sweet, there is still the selection of classic Chinese snacks called dim sum to satisfy and satiate. High tea is a meal to eat with eye and mouth, an in-between indulgence that should be light enough not to spoil dinner, but sufficiently robust to take the edge off the hunger that strikes hours after lunch. The afternoon tea special at Shang-Xi at the Four Seasons Hotel Pudong has just the right elements. It is a pampering meal, with touches of luxury that make the high tea session a treat in itself. Whole baby abalones are braised and then topped on a shortcrust pastry shell, a sort of Chinese version of the Western vol-au-vent, but classier. Even classier is the dim sum staple shrimp dumpling or hargow, upgraded with the addition of slivers of midnight dark truffles. This is a master touch, and chef Simon Choi, who presides unchallenged at Shang-Xi, has scored a winner again. Sweet prawns and aromatic truffles whats not to love? His masterful craftsmanship is exhibited in yet another pastry a sweet pastry that is shaped to look like a walnut, but which you can put straight into the mouth. It crumbles immediately, and the slightly sweet, nutty morsel is so easy to eat youll probably reach

溫馨提示

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

評論

0/150

提交評論