#include<iostream.h>
class Point
{
private:
int m_iXPos1;
int m_iYPos1;
int m_iXPos2;
int m_iYPos2;
public:
Point();
Point(int x1,int y1,int x2,int y2)
{
m_iXPos1=x1;
m_iYPos1=y1;
m_iXPos2=x2;
m_iYPos2=y2;
}
~Point()
{}
int GetRectArea()
{
int iWidth=m_iXPos2-m_iXPos1;
int iHeight=m_iYPos2-m_iYPos1;
int iArea=iWidth*iHeight;
return iArea;
}
};
void main()
{
Point p(0,0,10,20);
cout<<p.GetRectArea();
}
此程序在vc6.0下编译通过