cpp
#include <iostream>
using namespace std;
class Rect
{
private:
int width;
int height;
public:
void init(int w,int h)
{
width = w;
height = h;
}
void set_w(int w)
{
width = w;
}
void set_h(int h)
{
height = h;
}
void show()
{
cout << "矩形的周长为:" << (width + height) * 2 << endl;
cout << "矩形的面积为:" << width * height << endl;
}
};
int main()
{
Rect r1;
r1.init(15,20);
r1.show();
r1.set_h(5);
r1.set_w(8);
r1.show();
return 0;
}