思维导图:
#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 << "perimeter = " << (2*width+2*height) << endl;
cout << "area = " << width*height << endl;
}
};
int main()
{
Rect rect;
rect.init(1,1);
rect.set_h(4);
rect.set_w(5);
rect.show();
return 0;
}