设计并测试一个名为Retangle的矩形类,其属性为矩形的左下角与右上角两个点的坐标,能计算矩形的面积
问题描述:
设计并测试一个名为Retangle的矩形类,其属性为矩形的左下角与右上角两个点的坐标,能计算矩形的面积
答
#include
#include
class CPoint
{
public:
CPoint(float cx = 0,float cy = 0)
{
x = cx;
y = cy;
}
protected:
float x,y;
};
class CRect :public CPoint
{
public:
CRect(float left,float top,float right,float bottom):CPoint(left,top)
{
R = right;
B = bottom;
}
void Zlength()
{
cout