C++实验报告(5)

学生实验报告

C++实验报告(5)

一、实验综述

1、实验目的及要求

完成以下上机题目

1. Given a Rectangle class, which has Width and Height attributes and the following behaviors:

(1) Init(): to initialize the Width and Height

(2) SetWidth(): to set Width

(3) SetHeight(): to set Height

(4) GetWidth(): to get Width

(5) GetHeight(): to get Height

(6) Area(): to calculate the area of the rectangle

(7) DispInfo(): to show the information of the rectangle such as Width, Height and area.

Please analyze and design the class based on the above requirements.

2. Design a class Circle, which can be used to calculate the area and circumference of a circle. The radius is set when initializing an object. Please give a main function to call the class.

3. Design a Rectangle class with two attributes, Width and Height and to satisfy the following requirements. When the object is initialized by two arguments, which represent Width and Height respectively. But, when the object is initialized by only one argument, which means the rectangle is a square. There is a member function to show the area of the Rectangle in the class. Please also give a main function to call the class.

2、实验仪器、设备或软件

实验所用仪器:电脑

实验所用软件:visual c++ 6.0

二、实验过程(实验步骤、记录、数据、分析)

1. 定义一个长方形Rectangle类,它有宽、高(Width,Height)和一些计算方法:

(1) Init():设定宽、高的初始值

(2) SetWidth():设定宽度

你可能喜欢

  • 化学实验报告
  • 物理实验报告
  • 网上书店实验报告
  • 会计模拟实验报告
  • erp实验报告
  • c语言实验报告
  • 编译原理实验报告
  • spss实验报告

C++实验报告(5)相关文档

最新文档

返回顶部