




下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
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年仙桃市高新技术产业投资有限公司招聘真题
- 2025年小升初奥数试卷及答案
- 2024消防知识50题竞赛题库(含答案)
- 2025年注册测绘师考试测绘地理信息产业发展机遇试卷及答案
- 医学X射线诊断与介入放射学考试题及答案
- 上岗资质认证试题及答案(组装机械)
- 传染病鼠疫、炭疽防治知识培训考核试题及答案
- 2024年国家公务员考试行政能力测试真题及答案
- 2025国家珠宝玉石首饰检验集团有限公司招聘笔试历年参考题库及答案
- 2025年城市轨道交通车辆基础考核试题及答案
- 2025考研408计算机基础综合真题及答案
- 职业病危害因素检测与评价-工作场所空气中粉尘浓度的测定
- 四川省广安市2024-2025学年高一下学期期末考试数学试题(含答案)
- 展台搭建施工管理办法
- 电缆测试技术课件
- 政协大走访活动方案
- 个人养老金课件
- 儿科穴位贴敷治疗讲课件
- 2025年湖北省中考英语试题(附答案)
- udi追溯管理制度
- 三一研发项目管理制度
评论
0/150
提交评论