1
#include <iostream>
using namespace std;
class Rect
{
private:
int w;
int h;
public:
void init(int w,int h)
{
Rect:: w = w;
this -> h = h;
}
int set_h()
{
int h2;
cout << "请输入新的高度:" <<endl;
cin >> h2;
return h2;
}
int set_w()
{
int w2;
cout << "请输入新的宽度:" <<endl;
cin >> w2;
return w2;
}
void show(int h,int w)
{
cout << "周长 = " << (h+w)*2 <<endl;
cout << "面积 = " << h*w <<endl;
}
};
int main()
{
int w=0;
int h = 0;
Rect rect1;
rect1.init(w,h);
w = rect1.set_w();
h = rect1.set_h();
rect1.show(w,h);
return 0;
}