思维导图
Rect类
#include <iostream>
using namespace std;
class my_Rect
{
private:
int width;
int height;
public:
//初始化
void init()
{
cout << "please ener w and h" << endl;
cin >> width;
cin >> height;
cout << "success" << endl;
}
//更改长度和宽度
void set_rect(int w,int h)
{
width=w;
height=h;
cout << "success" << endl;
}
void show()
{
cout <<"面积:" << width*height << endl;
}
};
int main()
{
my_Rect AA;
AA.init();
AA.show();
AA.set_rect(2,10);
AA.show();
return 0;
}