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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

本文(实验三继承与派生.docx)为本站会员(b****6)主动上传,冰点文库仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰点文库(发送邮件至service@bingdoc.com或直接QQ联系客服),我们立即给予删除!

实验三继承与派生.docx

1、实验三继承与派生实验三-继承与派生本科实验报告课程名称: C+面向对象程序设计 实验项目: 实验地点: 明向校区 专业班级: 软件1419 学号: 2014006061 学生姓名: 刘国鑫 指导教师: 王丽娟 2015年5月10日实验名称 实验三 继承与派生实验目的1. 理解继承与派生的概念;2. 掌握派生类定义格式与使用方法;3. 初步掌握派生类构造函数的定义与使用方法,理解构造函数的调用过程,及基类成员的初始化过程;4. 理解冲突、支配规则与赋值兼容性原则的概念;实验要求1. 完善、编写程序,并调试程序,要给出测试数据和实验结果;2. 整理上机步骤,总结经验和体会;3. 完成实验报告和上交

2、程序。实验内容考察一个点、圆、圆柱体的层次结构,计算圆和圆柱体的面积,阅读程序并运行。主要仪器设备台式或笔记本电脑实验记录(写出实验程序代码及运行结果)#include#includeusing namespace std;class Point friend ostream &operator(ostream &,const Point &);public: Point(int=0,int=0); void setPoint(int,int); int getX() constreturn x; int getY() constreturn y; protected: int x,y;cla

3、ss Circle:public Point friend ostream &operator(ostream &,const Circle &); public: Circle(double r=0.0,int x=0,int y=0); void setRadius(double); double getRadius() const; double area() const; protected: double radius;class Cylinder:public Circle friend ostream &operator(ostream &,const Cylinder &);

4、public: Cylinder(double h=0.0,double r=0.0,int x=0,int y=0); void setHeight(double); double getHeight() const; double area() const; double volume() const; protected: double height;Point:Point(int a,int b) setPoint(a,b);void Point:setPoint(int a,int b) x=a; y=b;ostream &operator(ostream &output,const

5、 Point &p) outputp.x,p.y=0?r:0);double Circle:getRadius() const return radius;double Circle:area() const return 3.14159*radius*radius;ostream &operator(ostream &output,const Circle &c) outputCenterc.x,c.y;Radius=setiosflags(ios:fixed|ios:showpoint)setprecision(2)=0?h:0);double Cylinder:getHeight() c

6、onst return height;double Cylinder:area() const return 2*Circle:area()+2*3.14159*radius*height;double Cylinder:volume() const return Circle:area()*height;ostream &operator(ostream &output,const Cylinder &cy) outputCenter=cy.x,cy.y;Radius=setiosflags(ios:fixed|ios:showpoint)setprecision(2)cy.radius;H

7、eight=cy.heightendl; return output;int main() Point p(70,110); coutThe initial location of p ispendl; p.setPoint(9,9); coutThe new location of p ispendl; Circle c(2.4,35,42); coutThe initial location and radius of c arencnArea=c.area()n; c.setRadius(4.15); c.setPoint(3,3); coutnThe new location and

8、radius of c arencnArea=c.area()n; Cylinder cyl(5.6,2.6,10,20); coutnThe initial location,radius and height of cyl arencylArea=cyl.area()nVolume=cyl.volume()n; cyl.setHeight(9); cyl.setRadius(4.35); cyl.setPoint(3,3); coutnThe new location,radius and height of cyl arencylArea=cyl.area()nVolume=cyl.volume()n; system(pause); return 0;运行结果:实验中遇到的问题和解决办法1.不能熟练设定类、运用类,通过多练一些相关题目解决;2.继承与派生的知识掌握还不是很牢固,导致有些程序题目解答不准确,通过重新学习,理性分析解决;心得体会继承与派生这部分内容相对自己来说较难掌握,想要做到熟练掌握比较困难,需要时间和大量精力来学习,并要多做练习。并且这部分编写是应简洁,不该繁琐。

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2