4.1 测试一个名为rectangle 得矩形类,其属性为矩形得左下角与右上角两个点得坐标 ,能计算矩形得面积。
#include 〈iostream。h>
class Rectangle
Rectangle (int top, int left, int bottom, int right);
~Rectangle () {}
int GetTop() const { return itsTop; }
int GetLeft() const { return itsLeft; }
int GetBottom() const { return itsBottom; }
int GetRight() const { return itsRight; }
void SetTop(int top) { itsTop = top;
void SetLeft (int left) { itsLeft = left; }
void SetBottom (int bottom) { itsBottom
void SetRight (int right) { itsRight = right; }
Rectangle::Rectangle(int top, int left, int bottom, int right)
int Rectangle::GetArea() const
int Width = itsRight-itsLeft;
int Height = itsTop — itsBottom;
Rectangle MyRectangle (100, 20, 50, 80 );
int Area = MyRectangle、GetArea();
cout <〈 "Area: " 〈〈 Area <〈 ”\n";
return 0;