Rudia
Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору #include<iostream> using namespace std; class Rectangle { public: // Height of the rectangle double Height; // Width of the rectangle double Width; //Construct a rectangle Rectangle() { Height = 1; Width = 1; } //Construct a rectangle object Rectangle(double h, double w) { Height = h; Width = w; } // Return the area double getArea() { return Height * Width; } // Return the perimeter double getPerimeter() { return Height + Height + Width + Width; } }; int main() { Rectangle* rectangle1 = new Rectangle(50,5); Rectangle* rectangle2 = new Rectangle(35.9,3.5); cout << rectangle1->getArea() << endl; cout << rectangle2->getArea() << endl; } |