- 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;
}
/
                您可能关注的文档
最近下载
- 大班社会《危险游戏我不玩》.pptx VIP
- 2025年山西运城事业单位考试笔试试题(含答案).pdf
- 城市轨道交通运营设备维修与更新技术规范第5部分:通信.pdf VIP
- 医院感染暴发事件应急处理.pptx VIP
- 《食品营养学》 课件 第四章 各类食物的营养特点.pdf
- 基于BIM的建设工程文件归档管理系统.pdf VIP
- 护理学(专升本)模考试题(含参考答案).docx VIP
- 员工离职申请表(模版)(标准版).doc VIP
- 实验五___DPS统计分析操作.pptx VIP
- 《Unit 3 Lesson 3 Letters all around》(说课稿)-2024-2025学年冀教版(三起)(2024)英语三年级上册.docx VIP
 原创力文档
原创力文档 
                        

文档评论(0)