面向对象程序设计与C++语言习题答案朱战立版Word格式.docx
- 文档编号:18564607
- 上传时间:2022-12-28
- 格式:DOCX
- 页数:9
- 大小:47.86KB
面向对象程序设计与C++语言习题答案朱战立版Word格式.docx
《面向对象程序设计与C++语言习题答案朱战立版Word格式.docx》由会员分享,可在线阅读,更多相关《面向对象程序设计与C++语言习题答案朱战立版Word格式.docx(9页珍藏版)》请在冰豆网上搜索。
3
4
5
6
7
8
9
10
B
C
A
11
12
13
14
15
16
17
18
19
20
D
(1)
(2)
(3)a
(4)2
(5)2
(6)1
(7)3
(8)正确
(9)正确
(10)错误
(11)AB(AB&
a)
(12)delete[]pa;
(13)只能不能
(14)初始化
3.2选择题
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
3.30程序阅读题
con1called.
con2called.
con3called.
a=0,b=0
a=10,b=10
a=10,b=20
45
55
(3)
(4)
Xuxiaokai
Weirong
Destructor!
(5)
158
(6)
1234
000
XxkXxkXxk
XxkXxkXxkXxk
(7)
56
920
(8)
d=800
f=40
第4章
4.1填空题
(1)类名:
:
(2)优先级
(3)1
4.2选择题
参考资源:
[1]
[2]返回引用类型的函数:
1返回的是比较大的对象,采用引用类型以提高效率。
2该函数在表达式中作为左值出现。
例如:
#include"
stdafx.h"
#include<
iostream.h>
classPoint{
private:
intobj_x;
intobj_y;
public:
Point(inta=0,intb=0):
obj_x(a),obj_y(b){}
int&
x();
y();
};
int&
Point:
x()
{
returnobj_x;
}
y()
returnobj_y;
intmain(intargc,char*argv[])
PointThePoint;
//x()和y()作为左值
ThePoint.x()=7;
ThePoint.y()=9;
//x()和y()作为右值
cout<
<
"
x="
<
ThePoint.x()<
\n"
y="
ThePoint.y()<
;
return0;
第5章
5.1填空题
(1)保护和公有私有
派生类的成员函数可以直接访问基类的保护和公有成员,不能直接访问基类的私有成员。
(2)保护和公有所有
(3)private私有
(4)类名
(5)virtual
5.2选择题
(9)答案可参考测试程序
5.17阅读程序,给出运行结果
(1)10,10
6,6
7,9:
(2)Point:
34
Circleradius:
5
Circledestructor!
Pointdestructor!
(3)Poin:
Textcon!
PointwithTextcon!
PointwithTextdes!
Textdes!
Pointdes!
(4)2000/1/1
0:
0:
2002/10/1
23:
59:
59
2002/12/31
(5)2001/1/1
5:
30:
6:
20:
2003/3/8
7:
(6)Base(1,2)
Next(10,15)
Base(5,7)
(7)10,20,30,40
15,26,30,40
15,26,210,280
第6章
6.10
B_objx=100
D_objy=200
B_objx=300
D_objy=400
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 面向 对象 程序设计 C+ 语言 习题 答案 朱战立版
![提示](https://static.bdocx.com/images/bang_tan.gif)