欢迎来到天天文库
浏览记录
ID:41698013
大小:55.50 KB
页数:8页
时间:2019-08-30
《自学考试C++模拟试题二答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、自学考试C++模拟试题二答案一、选择题1.C2.C3.C4.D5.A6.D7.C8.C9.D10.B11.B12.A13.C14.A15.B16.C17.A18.A19.D20.C二、填空题21.对象名称.消息类型(参数)22.对象名称.find(要查找的字符串,开始查找的位置)。23.非函数模板24.protected。25.一个实例。26.抽象27._#define_28.____数据成员_________和_______成员函数_______29.___inline______。30._传值和传引用
2、________。31._________函数func的返回值为字符型的引用,一个参数是字符型,另一个参数是整数32.构造函数33.__vector_34._typedefvector<数据类型>::iterator泛型指针名__________35.delete36.237.___函数名相同,参数个数或参数类型不同________________-。38.__数据成员_______和______成员函数_____-。1.private。2.public三、程序改错1.(第四章)#include3、ream.h>ClassSample{Public:Sample(inta=0,intb=1);Voiddisp()Private:intx,y;}Sample::Sample(inta=0,intb=1);Sample::Sample(inta,intb);{x=a;y=b;}VoidSample::disp(){Cout<<“x=”<ClassSample{Public:VoidSample(inta){val4、ue=a;}intMax(intx,inty){returnx>y?x:y;}intMax(intx,inty,intz=0)intMax(intx,inty,intz){if(x>y)returnx>z?x:z;elsereturny>z?y:z;}~sample(){value=0;}Private:intvalue;}Voidmain(){Samplea;A.max(10,20);}3.(第六章)classBase{public:intb1;intb3;protected:intb2:};Class5、D2:private:BaseClassD2:public:Base{public:voidtest(){b1=8;b2=9;b3=10;}};ClassD2:public:D2{public:voidtest(){b1=11;b2=12;b3=13;}};4.(第六章)#includeclassA{Public:voidf(inti){cout<6、:voidh(){cout<<“B”;}A::f;};voidmain(){Bbb.f(10)b.g();或者注释此句b.h();}5.classTV{Public:voidSetStation(intstation);intgetStation()const;intitsStation;};intmain(){TVmyTV;myTV.itsStation=9;TVmyOtherTV(2);TVmyOtherTV();myOtherTV.SetStation(2);四、程序填空1.程序的输出结果如下:7、6G请根据输出结果在下面程序中的下划线处填写正确的语句。#includeclassA{Public:voidf(inti){cout<8、h>classM{Public:voidSet(inti,intj){m1=i;m2=j;}voidPrint(){cout<
3、ream.h>ClassSample{Public:Sample(inta=0,intb=1);Voiddisp()Private:intx,y;}Sample::Sample(inta=0,intb=1);Sample::Sample(inta,intb);{x=a;y=b;}VoidSample::disp(){Cout<<“x=”<ClassSample{Public:VoidSample(inta){val
4、ue=a;}intMax(intx,inty){returnx>y?x:y;}intMax(intx,inty,intz=0)intMax(intx,inty,intz){if(x>y)returnx>z?x:z;elsereturny>z?y:z;}~sample(){value=0;}Private:intvalue;}Voidmain(){Samplea;A.max(10,20);}3.(第六章)classBase{public:intb1;intb3;protected:intb2:};Class
5、D2:private:BaseClassD2:public:Base{public:voidtest(){b1=8;b2=9;b3=10;}};ClassD2:public:D2{public:voidtest(){b1=11;b2=12;b3=13;}};4.(第六章)#includeclassA{Public:voidf(inti){cout<6、:voidh(){cout<<“B”;}A::f;};voidmain(){Bbb.f(10)b.g();或者注释此句b.h();}5.classTV{Public:voidSetStation(intstation);intgetStation()const;intitsStation;};intmain(){TVmyTV;myTV.itsStation=9;TVmyOtherTV(2);TVmyOtherTV();myOtherTV.SetStation(2);四、程序填空1.程序的输出结果如下:7、6G请根据输出结果在下面程序中的下划线处填写正确的语句。#includeclassA{Public:voidf(inti){cout<8、h>classM{Public:voidSet(inti,intj){m1=i;m2=j;}voidPrint(){cout<
6、:voidh(){cout<<“B”;}A::f;};voidmain(){Bbb.f(10)b.g();或者注释此句b.h();}5.classTV{Public:voidSetStation(intstation);intgetStation()const;intitsStation;};intmain(){TVmyTV;myTV.itsStation=9;TVmyOtherTV(2);TVmyOtherTV();myOtherTV.SetStation(2);四、程序填空1.程序的输出结果如下:
7、6G请根据输出结果在下面程序中的下划线处填写正确的语句。#includeclassA{Public:voidf(inti){cout<8、h>classM{Public:voidSet(inti,intj){m1=i;m2=j;}voidPrint(){cout<
8、h>classM{Public:voidSet(inti,intj){m1=i;m2=j;}voidPrint(){cout<
此文档下载收益归作者所有