ImageVerifierCode 换一换
格式:DOCX , 页数:11 ,大小:17.67KB ,
资源ID:3029757      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/3029757.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(C++面向对象程序设计模拟试题2.docx)为本站会员(b****5)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

C++面向对象程序设计模拟试题2.docx

1、C+面向对象程序设计模拟试题2C+面向对象程序设计模拟试题二一、单项选择题(本大题共10小题,每小题2分,共20分)在每小题列出的四个备选项中,只有一个是符合题目要求的,请将其代码填写在题后的括号内。错选、多选或未选均无分。1说明内联函数的关键字是( )。A)inline B)virtual C)define D)static2假定CAb为一个类,则执行CAb oX;语句时将自动调用该类的( ) A)有参构造函数 B)无参构造函数 C)拷贝构造函数 D)赋值重载函数 3cin是某个类的标准对象的引用,该类是( )。 A)ostream B)istream C)stdout D)stdin4下面

2、的哪个保留字不能作为函数的返回类型?( )A)void B)int C)template D)long5派生类的成员函数不能访问基类的( )。A)保护成员 B)公有成员C)私有成员 D)前面各选项都正确6在语句“cout data;”中,cout是( )。A)C+的关键字 B)类名C)对象名 D)函数名7编译时多态性使用什么获得?( )A)重载函数 B)继承 C)虚函数 D)B和C 8拷贝构造函数的参数通常是( )。 A)无特殊要求 B. 指向对象的指针 C)本类对象的常引用 D)对象9C+有几种联编?( ) A)1种 B)2种 C)3种 D)4种10基类和派生类可以分别称为( )。 A)“大

3、类”和“小类” B)“父类”和“子类” C)“小类”和“大类” D)“子类”和“父类”二、填空题(本大题共5小题,每小题2分,共10分)不写解答过程,将正确的答案写在每小题的空格内。错填或不填均无分。1设函数max是由函数模板实现的,并且max(3.5, 5)和max(3, 5)都是正确的函数调用,则此函数模板具有( )个类型参数。2在C+中,函数重载与虚函数帮助实现了类的( )性。3由static修饰的数据成员为该类的所有对象( )。4重载函数一般在参数类型或参数个数上不同,但( )相同。5使用new建立的动态对象在不用时应该用( )释放所占用的空间。三、程序分析题(本大题共6小题,每小题5

4、分,共30分)给出下面各程序的输出结果。1阅读下面程序,写出输出结果。#include using namespace std;class Pointpublic: Point(int a = 0, int b = 0):x(a), y(b) int GetX() const return x; int GetY() const return y; void SetX(int a) x = a; void SetY(int a) y = a; private: int x; int y;int main() Point u; const Point v(6, 8); cout u.GetX()

5、 endl; u.SetX(16); cout u.GetX() endl; u.SetY(18); cout u.GetY() endl; cout v.GetX() endl; cout v.GetY() endl; return 0;上面程序的输出结果为:2阅读下面程序,写出输出结果。#include using namespace std;template class Testpublic: Test(Type a, int iSize):elem(a) size = iSize; void Print() const for (int i = 0; i size; i+) cout

6、elemi ; private: Type *elem; int size;int main() int a = 1, 0, 8; double b = 1.6, 1.8; Test ar1(a, 3); ar1.Print(); Test ar2(b, sizeof(b) / sizeof(double); ar2.Print(); cout endl; return 0;上面程序的输出结果为:3阅读下面程序,写出输出结果。#include using namespace std;class Goodspublic: Goods(int w): weight(w) totalWeight =

7、 totalWeight + w; Goods(const Goods &g) weight = g.weight; totalWeight = totalWeight + weight; Goods() totalWeight = totalWeight - weight; void Print() const; static int GetTotalWeight() return totalWeight; private: int weight; static int totalWeight;int Goods:totalWeight = 0; void Goods:Print() con

8、st cout weight totalWeight ;int main() Goods g1(6); g1.Print(); Goods g2(g1); g2.Print(); cout Goods:GetTotalWeight(); cout endl; return 0;上面程序的输出结果为:4阅读下面程序,写出输出结果。#include using namespace std;template class Testpublic: Test(Type a = 0, Type b = 0, Type c = 0):z(c) x = a; y = b; void Print() cout x

9、 endl; cout y endl; void Print() const cout z endl; private: Type x, y; const Type z;int main() Test t1; t1.Print(); Test t2(1, 9, 6); t2.Print(); const Test t3(0, 6, 1.8); t3.Print(); return 0;上面程序的输出结果为:5阅读下面程序,写出输出结果。#include using namespace std; template Type Max(const Type &a, const Type &b) if

10、 (a b) return b; else return a; template Type Min(const Type &a, const Type &b) if (a b) return a; else return b; int main() double x = 5.38, y = 6.09; cout Max(x, y) Max(x, y) ; cout Min(x, y) Min(x, y) endl; return 0; 上面程序的输出结果为:6阅读下面程序,写出输出结果。#include using namespace std; class Apublic: A() cout

11、A endl; A() cout A endl; ;class B: public Apublic: B() cout B endl; B() cout B endl; ;int main(void) B obj; return 0; 上面程序的输出结果为:四、完成程序填题(本大题共4个小题,每小题3分,共12分)下面程序都留有空白,请将程序补充完整。1将如下程序补充完整。#include using namespace std; class Aprivate: int n; public: A(int n) 1 = n; / 将数据成员n初始化为形参n void Show() const c

12、out n endl; ;int main() A i = 8; i.Show(); return 0; 2将如下程序补充完整。#include using namespace std; class Aprivate: int a; public: A(int m): a(m) void Show() const cout a endl; ;class B: Apublic: B(int m): 2 / 将数据成员a初始化为m void Show() const A:Show(); ;int main() B obj(8); obj.Show(); return 0; 3将如下程序补充完整。#include using namespace std; class Testprivate: static int num; public: Test() num+; Test() num-; static void ShowObjectNum() cout num endl; ;

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1