#include
using namespace std;
class Rect
{
private:
int width;
int height;
public:
Rect(int w,int h):width(w),height(h)
{}
void set_w(int w)
{
this->width=w;
}
void set_h(int h)
{
Rect::height=h;
}
void show()
{
cout << "长X宽= " << width*height << endl;
}
};
int main()
{
Rect s1(2,4);
int h,w;
cout <<"请输入宽";
cin >>w;
cout <<"请输入高";
cin >>h;
s1.set_h(h);
s1.set_w(w);
s1.show();
return 0;
}
Xmind