[计算机类试卷]国家二级(C++)机试模拟试卷66及答案与解析.doc
《[计算机类试卷]国家二级(C++)机试模拟试卷66及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(C++)机试模拟试卷66及答案与解析.doc(31页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( C+)机试模拟试卷 66及答案与解析 一、选择题 1 下列语句中,错误的是 ( )。 ( A) constintbuffer=256; ( B) constdouble*point; ( C) intconstbuffer=256; ( D) double*constpoint; 2 以下关键字不能用来声明类的访问权限的是 ( )。 ( A) public ( B) static ( C) protected ( D) private 3 下列关于 C+预定义流对象的叙述中,正确的是 ( )。 ( A) cin是 C+预定义的标准输入流对象 ( B) cin是 C+预定义的标准输入
2、流类 ( C) cout是 C+预定义的标准输入流对象 ( D) cout是 C+预定义的标准输入流类 4 有如下程序: #include using namespace std; int main() int sum; for(int i = 0; i using namespace std; int main() int a6=27,57,20,42,56,18; int s1,s2; s1=s2=a0; for(int* p=a+1;p-a*p?*p:s1; s2=s2 using namespace std; void fun(int x=y/4; x+; int main() int
3、 x=4,y=5; fun(x,y); cout using namespace std; class AA char c; public: AA(char ch):c(ch) AA() cout using namespace std; void fun(int x=y/4; x+; int main() int x=4,y=5; fun(x,y); coutbark() ( D) (*p).bark() 20 执行下 列语句段后,输出字符 “*“的个数是 ( )。 for (int i=50; i1; -i) cout #include using namespace std; class
4、 Instrument public: Instrument(string t=“乐器 “,string n=“无名 “):type(t),name(n) virtual string GetType() const return “乐器 “; string GetName() const return “无名 “; protected: string type,name; ; class Piano:public Instrument public: Piano(string n,string t=“钢琴 “):Instrument(t,n) string GetType() const r
5、eturn “钢琴 “; string GetName() const return name; ; int main() Instrument *pi=new Piano(“星空 “); coutGetType()GetName(); delete pi; return 0; 运行时的输出结果是 ( A)乐器 -星空 ( B)乐器 -无名 ( C)钢琴 -星空 ( D)钢琴 -无名 25 下列语句或语句序列中有语法错误的是 ( A) inti,j;for(i=0,j=0;i using namespace std; class Shape /图形类 public: /图形绘制函数(用显示字母
6、模拟) virtual void draw()const coutdraw(); int main() Shape s; Triangle t; plot( plot( s=t; s.draw(); return 0; 运行这个程序的输出是 ( A) STT ( B) STS ( C) TSS ( D) TTT 30 为类 MyClass重载赋值运算符时,应将其重载为类的 ( A)静态函数 ( B)成员函数 ( C)友元函数 ( D)虚函数 31 若 Pay 是一个类名,则执行语句 Pay p1,p22,*p3; 时 Pay的构造函数被调用的次数是 ( A) 1 ( B) 2 ( C) 3 (
7、 D) 4 32 下列语句中,错误的是 ( )。 ( A) constintbuffer=256; ( B) constinttemp; ( C) constdouble*point; ( D) constdouble*rt=newdouble(5.5); 33 有如下程序: #include using namespace std; class MyClass public: MyClass() cout p2; MyTemp p33; 编译系统在处理上钢琴 -无名面的语句序列时,所生成的模板 MyTemp的实例的个数是 ( A) 1 ( B) 2 ( C) 3 ( D) 4 39 在名为
8、BigNumber 的类的类体中对运算符函数 double进行了如下 声明: operator double(BigNumber); 函数声明中有一个明显的错误,这个错误就是 ( A)参数表中不应该有任何参数 ( B)缺少对函数返回类型的说明 ( C)参数声明中缺少参数变量 ( D)函数声明中缺少函数体 40 在 C+流的输入输出格式控制中,使用操作符 setw,可以控制 ( A)输出精度 ( B)输出宽度 ( C)对齐方式 ( D)填充字符 二、基本操作题 41 请使用 VC6或使用【答题】菜单打开考生文件夹 pmjl下的工程 pmjl,该工程中包含程序文件 main cpp,其中有关 TV
9、Set(“电视机 ”)和主函数 main的定义。程序中位于每个 “ ERROR*found*”之后的一行语句有错误,请加以改正。改正后程序的输出结果应该是: 规格: 29英寸,电源:开,频道: 5,音量: 18 规格: 29英寸,电源:关,频道: -1,音量: -1 注意:只修改每个 “ ERROR*found*”下的那一行,不要改动程序中的其他内容。 #include usingnamespacestd; classTVSet “电视机 ”类 constintSize; intchannel;频道 intvolume;音量 boolon;电源开关: true表示开, false表示关 pub
10、lic: ERROR*found* TVSet(intsize) thiS-Size(size); channel: 0; volume=15; on=false; intgetSize()constreturnsize; ) 返回电视机规格 boolisOn()constreturnon; 返回电源开关状态 返回当前音量,关机情况下返回 -1 intgetVolume()constreturnisOn ()?volume: -1; ) 返回当前频道,关机情况下返回 -1 intgetChannel()constreturnisOn ()?channel: -1; ERROR*found* v
11、oidturnOnOff()const将电源在 “开 ”和 “关 ”之间转换 on=!on; ) voidsetChannelTo(intchan)设置频 道 (关机情况下无效 ) if(isOn() chan=0 chan=0 &vol usingnamespacestd; classBook “书 ”类 char*title;书名 intnum_pages;页数 char*writer;作者姓名 public: Book(constchar*thetitle, int pages, constchar*thewriter): num pages(pages) title=newcharst
12、rlen(thetitle)+1; strcpy(title, the_title); *found* strcpy(writer, thewriter); *found* Book()_ intnumOfPages()constreturnnum_ pages; 返回书的页数 constchar*theTitle()constreturntitle; 返回书名 constchar*theWriter()constreturnwriter; 返回作者名 ; classTeachingMaterial: publicBook “教材 ”类 char*course; public: Teachin
13、gMaterial(constchar*the title, intpages, constchar*the writer, constchar*thecourse) *found* : _ course=newcharstrlen(thecourse)+1; strcpy(course, the_course); TeachingMaterial()deletecourse; constchar*theCourse()constreturncourse; 返回相关课程的名称 ; intmain() TeachingMateriala_book(“C+语言程序设计 ”, 299, “张三 “,
14、 “面向对象的程序设计“); cout usingnamespacestd; clasSPerson char*idcardno; 用动态空间存储的身份证号 char*name;用动态空间存储的姓名 boolismale;性别: true为男, false为女 public: Person(constchar*pid, constchar *pname, boolpmale); Person() *1*found* _; constchar*getIDCardNO()const returnidcardno; ) constchar*getName()constreturnname; ) vo
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 模拟 66 答案 解析 DOC
![提示](http://www.mydoc123.com/images/bang_tan.gif)