定义 Rectangle 类
public class Rectangle
{
private int iHeight;
private int iWidth;
// 缺省构造函数
public Rectangle()
{
Height=0;
Width=0;
}
// 构造函数重载
public Rectangle(int w,int h)
{
Width=w;
Height=h;
}
// 属性:宽 的get和set访问器
public int Width
{
get
{
return iWidth;
}
set
{
iWidth=value;
}
}
// 属性:高 的get和set访问器
public int Height
{
get
{
return iHeight;
}
set
{
iHeight=value;
}
}
// 属性:面积 的get访问器
public int Area
{
get
{
return Height*Width;
}
}
// 重载操作符 ==
public static bool operator==(Rectangle a,Rectangle b)
{
return ((a.Height==b.Height)&&(a.Width==b.Width));
}
// 重载操作符 !=
public static bool operator!=(Rectangle a,Rectangle b)
{
return !(a==b);