Advertisement
Guest User

Untitled

a guest
Jul 27th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3. class Rectangle{
  4. private:
  5. int width;
  6. int height;
  7. public:
  8. Rectangle(){set(0,0);}
  9. Rectangle(int w,int h){set(w,h);}
  10. void set(int w,int h){width = w;height = h;}
  11. int getWidth(){
  12. return width;
  13. }
  14. int getHeight(){
  15. return height;
  16. }
  17. void show(void);
  18. int RecArea();
  19. int PerLength();
  20. };
  21. void Rectangle::show(){
  22. cout<<"Width = "<<width<<endl;
  23. cout<<"height = "<<height<<endl;
  24. }
  25. int Rectangle::RecArea(){
  26. return width*height;
  27. }
  28. int Rectangle::PerLength(){
  29. return (width+height)*2;
  30. }
  31. int main(){
  32. Rectangle rect;
  33. rect.set(3,4);
  34. rect.show();
  35. cout<<"Rectangle area = "<<rect.RecArea()<<endl;
  36. cout<<"Rectangle length = "<<rect.PerLength()<<endl;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement