#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<<endl;
}
};
int main()
{
Rect re;
re.init(4,5);
re.show();
re.set_w(6);
re.set_h(7);
re.show();
return 0;
}
输出结果: