当前位置:首页 > 编程笔记 > 正文
已解决

10_8C++

来自网友在路上 155855提问 提问时间:2023-10-09 05:37:49阅读次数: 55

最佳答案 问答题库558位专家为你答疑解惑

X-Mind

#include <iostream>using namespace std;
class Rect
{
private:int width;int heigjt;
public:void init(int w,int h){width = w;heigjt = h;}void set_w(int w){width = w;}void set_h(int h){heigjt = h;}void show(){cout << "矩形的周长" << (width+heigjt)*2 << endl << "矩形的面积" << width*heigjt << endl;}
};
int main()
{Rect r;int w=5,h=6;r.init(w,h);r.show();r.set_w(10);r.set_h(20);cout << "更改后" << endl;r.show();return 0;
}
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"10_8C++":http://eshow365.cn/6-17629-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!