2015年电大面向对象程序设计C--考试复习题资料小抄.doc

上传人:教**** 文档编号:88294566 上传时间:2023-04-24 格式:DOC 页数:9 大小:83.50KB
返回 下载 相关 举报
2015年电大面向对象程序设计C--考试复习题资料小抄.doc_第1页
第1页 / 共9页
2015年电大面向对象程序设计C--考试复习题资料小抄.doc_第2页
第2页 / 共9页
点击查看更多>>
资源描述

《2015年电大面向对象程序设计C--考试复习题资料小抄.doc》由会员分享,可在线阅读,更多相关《2015年电大面向对象程序设计C--考试复习题资料小抄.doc(9页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、一、选择题1、重载函数在调用时选择的依据中,错误的是A参数个数 B参数类型 C函数名字 D.函数类型2、有关构造函数的说法不正确的是A.构造函数名字和类的名字一样 B.构造函数在说明变量时自动执行C.构造函数无任何函数类型 D.构造函数有且只有一个3、下列关于C+函数的叙述中,正确的是( )。 A)每个函数至少要具有一个参数 B)每个函数都必须返回一个值 C)函数在被调用之前必须先声明 D)函数不能自己调用自己4、下列关于类和对象的叙述中,错误的是( )。 A)一个类只能有一个对象 B)对象是类的具体实例 C)类是对某一类对象的抽象 D)类和对象的关系是一种数据类型与变量的关系5、在C+中,用

2、于实现运行时多态性的是( )。 A)内联函数 B)重载函数 C)模板函数 D)虚函数6、下列关于运算符重载的叙述中,正确的是( )。 A)通过运算符重载,可以定义新的运算符 B)有的运算符只能作为成员函数重载 C)若重载运算符+,则相应的运算符函数名是+ D)重载二元运算符时,必须声明两个形参7、对于语句 coutxendl;错误的是描述是( )。 A)“cout”是一个输出流对象 B)“endl”的作用是输出回车换行 C)“x”是一个变量 D)“”称作提取运算符8、有如下类声明,则类MyDERIVED中保护的数据成员和成员函数的个数是( )。 class MyBASE private: in

3、t 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)19、下列关于派生类构造函数的描述中,错误的是A派生类构造函数应包含直接基类和所有间接基类的构造函数B派生类构造函数仅包含直接基类构造函数和其他(如子对象)类

4、构造函数等C派生类构造函数通常带有成员初始化表D派生类默认构造函数中隐含包括直接基类的默认构造函数10、已知在一个类体中包含如下函数原型: Volume operator-(Volume)const;,下列关于这个函数的叙述中,错误的是( )。 A)这是运算符-的重载运算符函数 B)这个函数所重载的运算符是一个一元运算符 C)这是一个成员函数 D)这个函数不改变类的任何数据成员的值11、执行如下的程序段后,输出结果是( )。 cout.fill(*); cout.width(6); cout.fill(#); cout 123 endl; A)#123 B)123# C)*123 D)123*

5、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 namespace14、实现运行时的多态性要使用( )。 A)重载函数 B)构造函数 C)析构函数 D)虚函数15、要实现动态联编,必须通过( )调用虚函数。 A)对象指针 B)成员名限定 C)对象名 D)派生类名16、以下( )成员函数表示纯虚函数。 A)virtual int vf(int); B)vo

6、id vf(int)=0; C)virtual void vf()=0; D)virtual void vf(int)17、在每个C+程序中都必须包含有这样一个函数,该函数的函数名为。A.mainB.MAINC.nameD.function18、设x和y均为bool量,则x&y为真的条件是。A.它们均为真B.其中一个为真C.它们均为假D.其中一个为假19、下面的哪个保留字不能作为函数的返回类型?。A.voidB.intC.newD.long20、假定a为一个整型数组名,则元素a4的字节地址为。A.a+4B.a+8C.a+16D.a+3221、假定AB为一个类,则执行“ABa(4),b3,*p2

7、;”语句时,自动调用该类构造函数的次数为。A.3B.4C.6D.922、假定要对类AB定义加号操作符重载成员函数,实现两个AB类对象的加法,并返回相加结果,则该成员函数的声明语句为:。A.ABoperator+(AB&a,AB&b)B.ABoperator+(AB&a)C.operator+(ABa)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的下列

8、定义中,正确的是( )。 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、125、应在下列程序划线处填入的正确语句是( )。 class Base public: vo

9、id 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,

10、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. 类中的成员函数可

11、以存取类中的私有数据C. 在类中,如果不作特别说明,所有的数据均为私有类型D. 在类中,如果不作特别说明,所有的成员函数均为公有类型32、C+语言中规定函数的返回值的类型是由A return语句中的表达式类型所决定 B 调用该函数时的主调用函数类型所决C 调用该函数时系统临时决定 D 在定义该函数时所指定的函数类型所决定33、有一个int类型变量,在程序中频繁使用,最好定义它为Aregister B auto C extern Dstatic 34、如果a=1,b=2,c=3,d=4,则条件表达式ab?a:cd?c:d的值为A1 B2 C3 D435、下列运算符中,在C+中不能重载运算符是A?

12、: B+ C- D=36、如果一个类至少有一个纯虚函数,那么就称该类为A抽象类 B虚基类 C派生类 D以上都不对37、在下列关键字中,用以说明类中公有成员的是Apublic Bprivate Cprotected Dfriend38、要求通过函数来实现一种不太复杂的功能,并且要求加快执行速度,选用A内联函数 B重载函数 C递归调用 D嵌套调用39、功能为对对象进行初始化的是A析构函数 B数据成员 C构造函数 D静态成员函数40、下述静态数据成员的特性中,错误的是 A说明静态数据成员时前边要加修饰符staticB静态数据成员要在类体外进行初始化C引用静态数据成员时,要在静态数据成员前加类名和作用

13、域运算符D静态数据成员不是所有对象所共有的41、在C+中,关于下列设置参数默认值的描述中,正确的是A不允许设置参数的默认值B设置参数默认值只能在定义函数时设置C设置参数默认值时,应该是先设置右边的再设置左边的D设置参数默认值时,应该全部参数都设置42、print()函数是一个类的常成员函数,它无返回值,下列表示中,正确的是 Avoid print() const Bconst void print()Cvoid const print() Dvoid print(const)二、填空题1、面向对象程序设计有四个主要特点,即抽象、封装、_和_。2、非成员函数应声明为类的_函数才能访问这个类的pr

14、ivate成员。3、派生类中的成员不能直接访问基类中的_成员。4、在用class定义一个类时,数据成员和成员函数的默认访问权限是_。5、运算符重载函数可能是类的_函数,也可以是类的_函数,还可以是普通函数。6、用流对象的成员函数控制输出格式时,用于设置字段宽度的流成员函数的名称是_,与之作用相同的控制符名称是_。7、含有纯虚函数的类称为_。8、使用cin和cout进行输入输出操作的程序必须包含头文件_ ,其语句格式为_ 。9、C+语言中使用const定义常量时需要指出_ 、_ 和 _ 。10、派生类的构造函数的初始化表中,通常应包含_ 构造函数和_ 构造函数。11、C+语言支持两种多态性,分别

15、是_ 和_ 。12、函数调用excc(v1,v2),(v3,v4,v5),v6);语句中实参的个数是_ 。 13、C+语言中的每条基本语句以作为结束符,每条复合语句以作为结束符。14、执行“coutchar(A+2)5的相反表达式为。18、假定一个一维数组的定义为“char*a8;”,则该数组所含元素的个数为,所占存储空间的字节数为。19、变量分为全局和局部两种,变量没有赋初值时,其值是不确定的。20、假定a是一个二维数组,则aij的指针访问方式为。21、假定一个结构类型定义为“structDinta;unionintb;doublec;D*d2;”,则该类型的大小为字节。22、对一个类中的数

16、据成员的初始化可以通过构造函数中的 实现,也可以通过构造函数中的实现。23、假定AB为一个类,则执行“ABa10;”语句时,系统自动调用该类的构造函数的次数为。242、假定类AB中有一个公用属性的静态数据成员bb,在类外不通过对象名访问该成员bb的写法为。三、程序的填空、程序的执行1、以下程序是定义一个计数器类counter,对其重载运算符“+”,请填空。class counter private: int n; public: counter() n=0; counter(int i)n=i; _ /运算符重载函数 counter t; t.n=n+c.n; return t; void d

17、isp() 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、写出执行下面程序的输出结果。void fun(int &x, int y) int t=x; x=y; y=t; i

18、nt main( ) int a2 = 23, 42; fun(a1,a0); std:couta0,a1std:endl; return 0; 27、写出执行下面程序的输出结果。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、写出执行下面程序的输出结果。class Base private: char c; public: Base(char n):c(n) virtual Bas

19、e()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

20、,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 d

21、isp(Girl &x) cout”Girl s name is:”x.name”,tel:”x.dialendl; void main() Girl e(“Liping”,”0379-5515179”);disp(e);其输出结果为: 程序中突出介绍了C+中用于对私有成员访问的什么概念。7. #include class basepublic:virtual void who()coutbase classendl;class derive1:public basepublic:void who()coutderivel class endl;class derive2:public bas

22、e public:void who()coutderive2 class who(); p=&obj2;p-who(); p=&obj3;p-who(); 四、编程题1、 编写一个程序,设计一个满足如下要求的Cdate类: 用下面的格式输出日期: 日/月/年; 输出在当前日期上加一天后的日期; 设置日期。2、编写一个程序设计一个栈操作类,包含入栈和出栈成员函数,然后入栈一组数据,出栈并显示出栈顺序。3、编写一个程序计算“三角形、正方形、圆形”三种图形的面积,要求:a)抽象出一个基类base;b)在其中说明一个虚函数用来求面积;c)利用派生类定义“三角形、正方形、圆形”;d)编写主函数。4、编写

23、程序,把从键盘上输入的一批整数(以-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 No

24、vember 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

25、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

26、 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 yea

27、rs 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.

28、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 ev

29、idently 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 br

30、and 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 real

31、ly 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

32、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 boa

33、sted 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 dessert

34、s 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

35、 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

36、, 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

37、-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,

38、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 a

39、nd 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 cultu

40、res 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 visua

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 教案示例

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁