按下列要求进行编程

来源:百度知道 编辑:UC知道 时间:2024/05/09 08:43:40
1,定义一个描述矩形的类rectangle,包括的数据成员有宽(width)和长(length);
2,计算矩形周长
3,计算矩形面积
4,改变矩形大小
用vc 6.0

//分给我
class Rectangle
{
double m_Width;
double m_Length;
public:
Rectangle(double width, double length)
: m_Width(width), m_Length(length) {}
double area() { return m_Width * m_Length; }
double circumference() { return 2 * (m_Width + m_Length); }
void change(double width, double length)
{
m_Width = width, m_Length = length;
}
};

#include <iostream>

using namespace std;

class Crectangle
{
public:
float area(float length, float width)
{
return length * width;
}
float circumference(float length, float width)
{
return 2 * ( length + width);
}
void change_rec(float *length, float *width)
{
float new_length,new_width;
cout << "Please input the new length and width of the rectangle : ";
cin