- 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实 验 报 告 实验课程: 数据结构实验 学生姓名: 王维 学 号: 6100212202 专业班级: 网络工程121班 2014年 06月 25日 目录 实验一:测试长方形 1 实验二:顺序表 10 实验三:非循环单链表 28 实验四:循环双链表 48 南昌大学实验报告 ---(1)测试长方形 学生姓名: 王维 学 号: 6100212202 专业班级: 网工121班 实验类型:□ 验证 □ 综合 ■ 设计 □ 创新 实验日期: 实验成绩: 【实验题目】 长方形C++类的定义与实现 【实验步骤】 需求分析 定义一个长方形类,能完成设置序号,设置长和宽,求长方形面积,以及重载拷贝初始化构造函数使之能直接通过=赋值。 概要设计 抽象长方形类: ADT Rectangle { 数据对象:D={序号,长,宽} 基本操作: void setNo(int i); void setLength(ElemType a); void setWidth(ElemType a); ElemType area(); Rectangle(const Rectangle otherD); } 详细设计 ①长方形类基类 ///////////////////////////////////////////////// //长方形数据结构C++声明(基类) ///////////////////////////////////////////////// template typename ElemType class Rectangle { public: //长方形的序号类 class RectangleNo { public: int no; }; void setNo(int i); void setLength(ElemType a); void setWidth(ElemType a); ElemType area(); // Rectangle(); Rectangle(const Rectangle otherD); virtual ~Rectangle(); protected: ElemType length; ElemType width; RectangleNo myNo; }; ///////////////////////////////////////////////// //长方形数据结构C++实现(基类) ///////////////////////////////////////////////// template typename ElemType RectangleElemType::Rectangle() { length = width = 0; cout 自动调用构造函数endl; } //拷贝构造函数 template typename ElemType RectangleElemType::Rectangle(const RectangleElemType otherD) { length = otherD.length; width = otherD.width; myNo = otherD.myNo; cout 自动调用拷贝初始化构造函数为(; coutlength,width)endl; } //析构函数 template typename ElemType RectangleElemType::~Rectangle() { cout\n 第myNo.no个长方形对象(length,width)生存期结束endl; } //功能:设置长方形的序号 template typename ElemType void RectangleElemType::setNo(int i) { myNo.no=i; } //功能:设置长方形长度 template typename ElemType void RectangleElemType::setLength(ElemType a) { length = a; } //功能:设置长方形宽度 template typename ElemType void RectangleElemType::setWidth(ElemType a) { width = a; } /
您可能关注的文档
最近下载
- 日照市基本医疗保险政策与经办业务知识考试题库2025 .pdf VIP
- 小学英语教学评一体化策略与实践.pptx VIP
- 中小学英语教学评一体化的理论与实践.pptx VIP
- 管理沟通——原理、策略及应用(第三版)课件全套 赵洱岽 第1--14章 管理沟通概论---数字化时代的沟通.pptx
- 小学英语教学评一体化的实践探究.pptx VIP
- 小学英语教学中“教—学—评”一体化教学策略运用.pptx VIP
- 北师大版六年级上册数学《百分数的认识》(课件)(共17张PPT).pptx VIP
- 2025村委换届考试题及答案.docx VIP
- 2024《小红书运动户外行业白皮书》.docx
- 推荐浙江省土建安全技术资料台帐(十二本).doc VIP
文档评论(0)