00001 #ifndef point_H 00002 #define point_H 00003 00004 class CPoint2d 00005 { 00006 public: 00007 float x; // 2d点的x坐标 00008 float y; // 2d点的y坐标 00009 float pointangle; 00010 00011 00012 public: 00013 // 构造函数 00014 CPoint2d(void); 00015 CPoint2d(float x,float y); 00016 ~CPoint2d(void); 00017 // 复制构造函数 00018 CPoint2d(const CPoint2d& tmpP); 00019 00020 // 重载运算符为成员函数 00021 CPoint2d & operator += ( const CPoint2d & p); 00022 CPoint2d & operator -= ( const CPoint2d & p); 00023 CPoint2d & operator *= ( float s ); 00024 CPoint2d & operator /= ( float s ); 00025 // 重载运算符为友元函数 00026 00027 friend bool operator == (const CPoint2d &p1,const CPoint2d &p2); 00028 friend bool operator != (const CPoint2d &p1,const CPoint2d &p2); 00029 friend CPoint2d operator + (const CPoint2d &p1 ,const CPoint2d &p2); 00030 friend CPoint2d operator - (const CPoint2d &p1 ,const CPoint2d &p2); 00031 friend CPoint2d operator * ( const CPoint2d &p , float s ); 00032 friend CPoint2d operator / (const CPoint2d &p ,float num); 00033 00034 // 点到原点的距离 00035 //double Dist(void); 00036 // 点到原点的距离 00037 float Dist(const CPoint2d &p); 00038 }; 00039 00040 #endif