- #include
-
- using namespace std;
- class rect
- {
- private:
- int width;
- int height;
- public:
- void init(int width , int height);
- void set_w(int width);
- void set_h(int height);
- void show();
- };
- void rect::show()
- {
- int c= (width + height) *2 ;
- int s=width * height;
- cout << c<< " ";
- cout << s<< endl;
- }
- void rect::init(int width, int height)
- {
- this -> width=width;
- this -> height=height;
- }
- void rect::set_w(int width)
- {
- this -> width=width;
- }
- void rect :: set_h(int height)
- {
- this -> height=height;
- }
-
- int main()
- {
- rect rec;
- rec. init (3,4);
- rec.show();
- rec.set_w(7);
- rec.show();
- rec.set_h(10);
- rec.show();
-
- return 0;
- }
