赞
踩
思维导图:
- #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;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。