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

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

最佳回答

谨慎的发卡

优秀的哈密瓜,数据线

2026-08-10 23:34:49

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-08-10 23:34:49

    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