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;
}