1、按下列要求编程:定义一个描述矩形的类Rectangle,包括的数据成员有宽(width)和长(length),并实现

学习 时间:2026-03-30 19:16:25 阅读:4343
1、按下列要求编程:定义一个描述矩形的类Rectangle,包括的数据成员有宽(width)和长(length),并实现如下功能函数;(1)矩形对象初始化;(2)计算矩形周长;(3)计算矩形面积;(4)改变矩形大小.

最佳回答

明亮的板栗

包容的墨镜

2026-03-30 19:16:25

class Recangle{private:int width;int length;public:Recangle(){width = 0; length = 0;};Recangle(int w,int h){width = w; height = h;};int circumference(){return 2*(width+height)};int Area(){return width * height};void changeRec(int w,int h){width = w; height = h;};};

最新回答共有2条回答

  • 刻苦的鸵鸟
    回复
    2026-03-30 19:16:25

    class Recangle{private:int width;int length;public:Recangle(){width = 0; length = 0;};Recangle(int w,int h){width = w; height = h;};int circumference(){return 2*(width+height)};int Area(){return width * height};void changeRec(int w,int h){width = w; height = h;};};

上一篇 水晶之恋是什么意思?

下一篇 为什么不能说connect the recorder with your computer