[计算机类试卷]国家二级C++机试(类和对象)模拟试卷23及答案与解析.doc
《[计算机类试卷]国家二级C++机试(类和对象)模拟试卷23及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(类和对象)模拟试卷23及答案与解析.doc(23页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(类和对象)模拟试卷 23及答案与解析 一、选择题 1 下列关于 this指针的描述中,正确的是 ( )。 ( A)类的成员函数都有 this指针 ( B)类的友元函数都有 this指针 ( C)任何与类相关的函数都有 this指针 ( D)类的非静态成员函数都有 this指针 2 有如下程序: #include using namespace std; class Test public: Test() n+=2; Test() n一 =3; static int getNum() return n; private: static int n; ; int Test: n
2、=1; int main() Test*p=new Test; delete p; cout using namespace std; class obj static int i; public: obj()i+; obj()i-; ) static int getVal()return i; ; int obj: i=0; void f()obj ob2; coutgetVal(); delete ob3; cout using namespace std; class MyClass public: MyClass()+count; MyClass()-count; static int
3、 getCountOreturn count; private: static int count; ; int MyClass: count=0; int main() MyClass ohj; coutgetPI();和 coutgetPI();和 coutgetPI(); ( D) cout using namespace std; class XA int a; public: static int b; XA(int aa): a(aa)b+; int getA()return a; ; int XA: b=0: int main() XA d1(4), d2(5); cout us
4、ing namespace std; int i=1; class Fun public: static int i; int value()return i-1; int value()constreturn i+1; ; int Fun: i=2; int main() int i=3: Fun fun1; const Fun fun2: return 0: 若程序的输出结果是: 123 则程序中下划线处遗漏的语句是 ( )。 ( A) cout using namespace std; class VAC public; int f() constreturn 3; int f()ret
5、urn 5; ; Int main() VAC v1; constVAC v2; cout using namespace std; class MyClass public: MyClass(int x): Val(x) void Set(int x)val=x; void Print()constcout using namespace std; class A public: A(int i): r1(i) void print() cout using namespace std; class A public: A(int i=0): r1(i) void prim()couta=a
6、; 第 2行 void g(char b)this-b=b; ) 第 3行 char h()constreturn a; 第 4行 ; 编译时没有错误的行是 ( )。 ( A)第 1行 ( B)第 2行 ( C)第 3行 ( D)第 4行 22 有如下类定义: classAA int a; public: int getRef()constreturn&a; int getValueoconstreturn a; void set(int n)consta=n; ) friend void show(AA aa)constcout using namespace std; class Samp
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 对象 模拟 23 答案 解析 DOC
