




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、、选择题123456789101112DDBDCBBABABC131415161718192021222324BDADADAABCDA、填空题1、实例,对象2、Public,private,protected3、Private,protected,public4、对象成员5、Private6、类名,对象7、构造函数&成员对象9、缺省构造函数10、main ()11、静态12、friend void fun();三、改错题1、 Obj2.f();错误,常对象不能访问不用const修饰的成员函数。2、X(int aa)a(aa) 初始化列表,改为 X(int aa):a(aa)或X(i nt aa
2、)a=aa;四、写程序执行结果1、con structori=5i=102、i=0,k=2i=0,k=23、Con structor55Destructor54、a=7,b=85、x=1,y=10,r=1x=2,y=10,r=2 disp1:x=1,y=96、disp2:x=2,y=8五、程序填空1、aabb2、MyClass(MyClass &mc) MyClass(MyClass &mc) mc.X Y=mc.Y3、void init(int k,int t);Couta.Getx() ”,”a.GetY()4、int test:x=5;Int test:fun()5、M a(1)a.sh
3、ow()6、return xA &r=a7、class two x=r.y8、return x int x9、int num,floatt.n六、编程题1、 #include using namespace std; class box public:box(float length,float height,float width); float v(); float s();private:float blength,bheight,bwidth; ;box:box(float length,float height,float width) blength=length;bheight=
4、height; bwidth=width;float box:v()return blength*bheight*bwidth;float box:s()return (blength*bheight+bheight*bwidth+bwidth*blength)*2;void main()float length,height,width; cinlengthheightwidth; box box1(length,height,width); coutbox1 的体积 :box1.v(); coutbox1 的表面积: box1.s();2、 #include #include using
5、namespace std;class pointpublic:point(float px,float py);point(point &p);void negate();float norm();void print();private:float x,y;point:point(float px,float py)x=px;y=py;point:point(point &p)x=p.x;y=p.y;void point:negate()x=-1.0*x;y=-1.0*y;float point:norm()return sqrt(x*x+y*y);void point:print()co
6、utx=xendl;couty=yendl;void main()point p1(1,2);p1.print();point p2(p1);p2.norm()endl;coutp1 距离为: p1.norm() p2 距离为: p1.negate();p1.print();3、#include using namespace std;class Vectorpublic:Vector(float x,float y);Vector();friend Vector add(Vector v1,Vector v2);friend Vector sub(Vector v1,Vector v2);f
7、loat getx()return vx;float gety()return vy;private:float vx,vy;Vector:Vector()Vector:Vector(float x,float y)vx=x;vy=y;Vector add(Vector v1,Vector v2)Vector v;v.vx=v1.vx+v2.vx;v.vy=v1.vy+v2.vy;return v;Vector sub(Vector v1,Vector v2)Vector v;v.vx=v1.vx-v2.vx ;v.vy=v1.vy-v2.vy;return v;void main()Vect
8、or vector1(1,2);Vector vector2(2,1);Vector vectoradd,vectorsub;vectoradd=add(vector1,vector2);vectorsub=sub(vector1,vector2);coutvectoradd=vectoradd.getx(),vectoradd.gety()endl; coutvectorsub=vectorsub.getx(),vectorsub.gety()endl;4、#include using namespace std;class studentpublic:student()totalstudents+;student()totalstudents-;static int Getstudentnumber()return to
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2024年6月电力电缆工岗位技能练习题
- 2025及未来5年中国鸣笛壶市场调查、数据监测研究报告
- 2025年法制宣传日普法活动法律知识竞赛试题库及答案
- 重难点解析人教版八年级上册物理声现象《声音的特性声的利用》定向测试试题(含详细解析)
- 粮店的营销方案(3篇)
- 国家安全教育进校园手抄报(3篇)
- 商务客服服务管理制度(3篇)
- 心理咨询方案线上订阅(3篇)
- 团建-活动策划方案(3篇)
- 体彩策划活动方案(3篇)
- 个人养老金课件
- 赛力斯深度研究报告:问界爆款引领携手华为筑底中长期发展
- 服务器、存储维保项目投标文件
- 2025-2030中国宠物托运服务行业运营状况与盈利前景预测报告
- 菜鸟驿站员工合同协议书
- 铝锭加工居间合同协议书
- 中国头颈部动脉夹层诊治指南(2024)解读
- 顶管分包合同协议
- 沟槽开挖隐蔽工程质量验收记录
- 亲情主题课件
- DB5133∕T 79-2023 九龙县古茶树管护技术规程
评论
0/150
提交评论