




已阅读5页,还剩9页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第 1 题 复合题 25 分 请认真复习课本第九章有关内容 完成下列题目 第 1 1 题 客观 多选题 5 分 include class CRect int length width public CRect length 10 width 20 cout Defaul constructing endl CRect int l int w length l width w cout Constructing endl CRect const CRect width ct width cout Copy constructing endl CRect cout Destructing length width endl void SetRect int l 0 int w 0 length l width w void disp cout The area is length width endl int main CRect r1 3 3 r2 r1 r3 r1 disp r2 disp r3 disp r1 SetRect 5 8 r1 disp return 0 请选择正确的叙述 A 类 CRect 有3个构造函数 1个析构函数 B 类 CRect 有2个构造函数 2个析构函 数 C 每个构造函数被调用1次 D 析构函数被调用3次 第 1 2 题 客观 多选题 5 分 include class CRect int length width public CRect length 10 width 20 cout Defaul constructing endl CRect int l int w length l width w cout Constructing endl CRect const CRect width ct width cout Copy constructing endl CRect cout Destructing length width endl void SetRect int l 0 int w 0 length l width w void disp cout The area is length width endl int main CRect r1 3 3 r2 r1 r3 r1 disp r2 disp r3 disp r1 SetRect 5 8 r1 disp return 0 r1 调用 CRect int l int w 构造 r2 调用 CRect const CRect public CRect length 10 width 20 cout Defaul constructing endl CRect int l int w length l width w cout Constructing endl CRect const CRect width ct width cout Copy constructing endl CRect cout Destructing length width endl void SetRect int l 0 int w 0 length l width w void disp cout The area is length width endl int main CRect r1 3 3 r2 r1 r3 r1 disp r2 disp r3 disp r1 SetRect 5 8 r1 disp return 0 程序输出包含下列内容 Constructing Copy constructing The area is 9 The area is 9 Defaul constructing The area is 40 Destructing 10 20 Destructing 3 3 Destructing 5 8 第 1 4 题 主观 题 5 分 请写出下列程序的输出结果 include include class Point public Point int xValue 0 int yValue 0 x xValue y yValue void setX int xValue 设置 x 坐标 x xValue int getX const 获取 x 坐标 return x void setY int yValue 设置 y 坐标 y yValue int getY const 获取 y 坐标 return y double distance const Point void Disp const cout getX getY private int x y x y 坐标 Point Offset Point tmp setX p1 getX p2 getX tmp setY p1 getY p2 getY return tmp int main Point p1 30 50 p2 10 10 p3 cout p1 location is p1 Disp cout endl cout p2 location is p2 Disp cout endl cout p3 location is p3 Disp cout endl p3 Offset p1 p2 cout p3 location is p3 Disp cout endl return 0 第 1 5 题 主观 题 5 分 请分析程序输出结果 回答问题 include class MyClass int num int copynum public MyClass int a 0 num a copynum 0 cout Construting endl MyClass MyClass cout Copy construting copynum copynum endl MyClass cout Destructing num num copynum copynum y 第四行 res x 第五行 else 第六行 res y 第七行 return res 第八行 第九行 请判断以下叙述是否正确 A 函数原型是 int func int x int y B 函数类型是 void C 这个函数有两个局部变量 D 从第二行到第九行称为 函数体 第 2 2 题 客观 多选题 5 分 有以下函数定义 int func int x int y 第一行 第二行 int res 第三行 if x y 第四行 res x 第五行 else 第六行 res y 第七行 return res 第八行 第九行 请判断以下叙述是否正确 这个函数被调用时可以用这个形式 int func int 10 int 20 这个函数被调用时可以用这个形式 func 10 20 变量 x y 的作用域是本函数 之内 如果有定义 int a 100 b 50 则可以用这个形式调用函数 func b a 第 2 3 题 客观 多选题 5 分 程序填空 为了使下列程序的输出结果是 1 2 3 4 5 6 7 8 9 10 请在横线上补充完整语句 int a 10 1 2 3 4 5 6 7 8 9 10 ap ap a for int k 0 k 10 k cout ap cout endl A a B ap C ap a k D ap a k 1 第 2 4 题 客观 单选题 5 分 下列程序的输出结果是 include void main int a 10 1 2 3 4 5 6 7 8 9 10 int ap a for int k 0 k 10 k ap if ap 2 0 cout ap cout endl A 1 2 3 4 5 B 6 7 8 9 10 C 1 3 5 7 9 D 2 4 6 8 10 第 2 5 题 客观 多选题 5 分 使下列程序能够输出 11 12 13 14 15 16 17 18 19 20 则横线上应该填写的语句是 include void main int a 10 1 2 3 4 5 6 7 8 9 10 int ap for ap a ap a 10 ap cout ap cout endl A ap 10 B ap ap 10 C ap 10 D ap ap 10 第 3 题 复合题 25 分 相关概念 变量 代表一个存储单元 这个存储单元可以由一个或多个内存字节组成 访问一个存储单元 可以有三种方式 使用变量名 使用指向变量的指针 使用变量的引用 函数 完成某些功能的语句集 由函数名 函数参数表 函数类型 函数体构成 其中函数 名 函数参数表 函数类型又称为函数头部 以下习题 请复习课本第一至七章并完成 第 3 1 题 客观 多选题 5 分 C 声明语句如下 int a ap 则 a ap 是变量名 也是变量名 的地址是 char cp float fp double dp 则表达式 sizeof ap sizeof cp sizeof fp sizeof dp 的值 是 A 4 1 4 8 B 4 4 4 4 C 4 1 8 8 D 2 1 4 8 第 3 3 题 客观 单选题 5 分 有语句如下 int m 10 int 则 下列语句的输出结果是 cout m m m t endl cout m 的地址是 m 10 t 随机数 m 的地址是 能够有确定值 t 的地址是 是随机数 m 10 t 是 m 的地址 m 的地址是 能够有确定值 t 的地址是 能够有确定值 但与 m 的地址不一 样 m 10 t 10 m 的地址是 t 的地址是 两个地址是一样的 m 10 t 随机数 m 的地址是 t 的地址是 两个地址是一样的 第 3 4 题 客观 多选题 5 分 void func int temp temp x x y y temp void main int a 10 b 20 func a b cout a a b b A int x int y B int x iny y C int cp return 0 void main char str Microsoft Visual C if func str s 0 cout str endl else cout Not found endl cp 0 cp 0 model 0 model 0 第 4 题 复合题 25 分 程序阅读与补充 第 4 1 题 主观 题 5 分 请写出程序运行输出结果 include class CRect int length width public CRect length 10 width 20 CRect int l int w length l width w void SetRect int l 0 int w 0 length l width w void disp cout The area is length width endl int main CRect r1 3 3 r2 5 8 r3 r1 disp r2 disp r3 disp return 0 第 4 2 题 主观 题 5 分 请写出程序运行结果 include class X public X int a 10 num a cout Constructing num num endl void SetX int a 200 num a int GetX return num X cout Destructing num num obj2 GetX cout The bigger one is obj1 endl else cout The bigger one is obj2 endl return 0 第 4 3 题 主观 题 5 分 请写出程序运行结果 include include class Point public Point int xValue 0 int yValue 0 x xValue y yValue void setX int xValue 设置 x 坐标 x xValue int getX const 获取 x 坐标 return x void setY int yValue 设置 y 坐标 y yValue int getY const 获取 y 坐标 return y double distance const Point void Disp const cout getX getY private int x y x y 坐标 int main Point p1 30 50 p2 10 10 p3 cout p1 location is p1 Disp cout endl cout p2 location is p2 Disp cout endl cout p3 location is p3 Disp cout endl p1 setX p1 getX 50 p1 setY p1 getY 100 cout Now p1 location is p1 Disp cout endl cout Distance from p1 to p3 p1 distance p3 endl cout Distance from p2 to p3 p2 distance p3 endl return 0 第 4 4 题 主观 题 5 分 以下程序中的类是一个不完整的类的定义 请根据输出结果补充完整 include include include class TwoDShape 二维图形类 double width height char name 20 public TwoDShape TwoDShape double TwoDShape double double TwoDShape double double const char na void showDim const void getName char sp const 根据类的规格中构造函数的声明 补充完整构造函数 void TwoDShape showDim const cout Width and height are width and height n cout The area of name is width height endl void TwoDShape getName char na const strcpy na name int main TwoDShape s1 s2 30 s3 10 30 s4 20 50 rectangle char str 80 cout object is s1 getName str cout str endl s1 showDim cout object is s2 getName str cout str endl s2 showDim cout object is s3 getName str cout str endl s3 showDim cout object is s4 getName str cout str endl s4 showDim return 0 输出结果是 object is unknown Width and height are 0 and 0 The area of unknown is 0 object is square Width and height are 30 and 30 The area of square is 900 object is rectangle Width and height are 10 and 30 The area of rectangle is 300 object is rectangle Width and height are 20 and 50 The area of rectangle is 1000 第 4 5 题 主观 题 5 分 请写出程序运行输出结果 include class Date private int year month day public Date int y 2002 int m 12 int d 31 year y month m day d 容错控制 year year 0 month this month day this day void main Date d1
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 商业零售店租赁经营合同协议
- 酒店管理与服务合同协议书
- 广东自考考试试卷及答案
- 2025年新疆特色果树制种合同
- 2025年新材料研发行纪合同协议书
- 2025年轨道交通信号工(高级技师)资格考试题库(带答案)
- 2025年广西专业技术人员继续教育公需科目科目考试及答案
- 护理部礼仪考试题及答案
- 客户服务响应流程优化管理工具
- 入团笔试题型及答案大全
- 财务部安全生产培训报告课件
- 公司兼职人员劳务合同4篇
- 制造过程质量追溯系统设计
- 2025年能源行业新能源产业风险管理可行性研究报告
- 会计毕业论文烟草专业
- 数字文旅概论 课件全套 第1-9章 数字文旅内涵与发展背景 - 数字营销
- 井盖安全常识培训课件
- 年产5万吨电熔锆刚玉新材料扩建项目环境影响报告表
- 2025社会工作员考试(社会工作基础知识)综合能力测试题及答案
- 卫生院支委会补选书记会议记录范文
- 酸洗作业安全知识培训
评论
0/150
提交评论