Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Rectangle
- {
- public:
- Rectangle(double w, double h) : width(w), height(h) {}
- double perimeter() const
- {
- return 2 * (width + height);
- }
- double area() const
- {
- return width * height;
- }
- private:
- double width, height;
- };
- int main()
- {
- double w, h;
- cin >> w >> h;
- Rectangle rect(w, h);
- cout << rect.area() << endl << rect.perimeter() << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment