CPoint该如何定义?
CPoint是一个MFC类,表示一个二维平面上的点,它的定义如下:
class CPoint { public: int x; int y;
public: CPoint(); CPoint(int x, int y); CPoint(POINT point); void Offset(int xOffset, int yOffset); void Offset(POINT point); void SetPoint(int x, int y); BOOL operator==(POINT point) const; BOOL operator!=(POINT point) const; void operator+=(SIZE size); void operator-=(SIZE size); void operator+=(POINT point); void operator-=(POINT point); CPoint operator+(SIZE size) const; CPoint operator-(SIZE size) const; CPoint operator-() const; CPoint operator+(POINT point) const; SIZE operator-(POINT point) const; };
其中,x和y分别表示点的横坐标和纵坐标,Offset方法用于移动点的位置,SetPoint方法用于设置点的坐标,各种运算符重载方法用于进行点的加减、比较等操作。
原文地址: http://www.cveoy.top/t/topic/bd6V 著作权归作者所有。请勿转载和采集!