一、思维导图
二、练习
#include <iostream>
using namespace std;
class Rect
{
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()
{
int per=2*(width+height);
int area=width*height;
cout << "周长为:" << per <<endl;
cout << "面积为:" << area << endl;
}
};
int main()
{
Rect rect;
int width,height;
cout << "请输入宽:" ;
cin >> width ;
cout << "请输入高:" ;
cin >> height ;
rect.init(width,height);
rect.show();
return 0;
}