[计算机类试卷]国家二级C++机试(类和对象)模拟试卷11及答案与解析.doc
《[计算机类试卷]国家二级C++机试(类和对象)模拟试卷11及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级C++机试(类和对象)模拟试卷11及答案与解析.doc(22页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级 C+机试(类和对象)模拟试卷 11及答案与解析 一、选择题 1 有如下类声明: class SAMPLE int n; public: SAMPLE(int i=0): n(i) void setValue(int n0; ; 下列关于 getValue成员函数的实现中,正确的是 ( )。 ( A) ( B) ( C) ( D) 2 下列关于类定义的说法中,正确的是 ( )。 ( A)类定义中包括数据成员 和函数成员的声明 ( B)类成员的缺省访问权限是保护的 ( C)数据成员必须被声明为私有的 ( D)成员函数只能在类体外进行定义 3 下列运算符函数中,肯定不属于类 Value的成
2、员函数的是 ( )。 ( A) Value operator+(Value); ( B) Value operator-(Value, Value); ( C) Value operator*(int); ( D) Value operator (Value); 4 有如下程序: #include using namespace std; class Point int x, y; public: Point(int x1=0, int y1=0): x(x1), y(y1) int get()return x+y; ; class Circle Point center; int radiu
3、s; public: Circle(int cx, int cy, int r): center(cx, cy), radius(r) int get()return center get()+radius; ; int main() Circle c(3, 4, 5); cout using namespace std; class Pair int m, n; public: Pair(int j, int k): m(j), n(k) int get()return m; ) int get()constreturn m+n; ; int main() Pair a(3, 5); con
4、st Pair b(3, 5); cout #include using namespace std; class MyClass public: MyClass()cout using namespace std; class Part public: Part(int x=0): val(x)cout #include using namespace std; class XCF int a; public: XCF(int aa=0): a(aa)coutGeta(); delete pd; return 0: ) 运行时的输出结果是 ( )。 ( A) 1215588 ( B) 121
5、8855 ( C) 12185 ( D) 128512 13 有如下程序: #include using namespace std; class Toy public: Toy(char*_n)strcpy(name, _n); count+; Toy()count-; char*GetName0return name; static int getCount()return count; private: char name10; static int count; ; int Toy: count=0; int main() Toy t1(“Snoopy“), t2(“Mickey“),
6、 t3(“Barbie“); cout using namespace std; class MyClass public: MyClass () cout #include using namespace std; class MyString public: char str80; MyString(const char*s)strcpy(str, s); MyString&operator+=(MyString a) strcat(str, a str); return*this; ; ostream&operator using namespace std; class Obj sta
7、tic int i; public: Obj()i+; Obj()i-; static int getVal()return i; ; int Obj: i=0; void f()Obj ob2; coutgetVal(); delete ob3; coutgetPI();和 coutgetPI();和 coutgetPI(); ( D) cout using namespace std; int i=1; class Fun public: static int i; int value()return i-l; int value()constreturn i+1; ; int Fun:
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 机试 对象 模拟 11 答案 解析 DOC
