overload greater than operator with or without friend
问题 Suppose I have the following class: class Point{ private: int x,y; public: int get_x() const {return x;} int get_y() const {return y;} Point() :x(0),y(0){} Point(int x,int y):x(x),y(y){} Point(const Point& P){ x = P.get_x(); y = P.get_y(); } Point& operator= (const Point& P) { x = P.get_x(); y = P.get_y(); return *this; } friend ostream& operator<<(ostream& os,const Point& P) { os<<"["<<P.get_x()<<", "<<P.get_y()<<"]"; return os; } Point operator - (const Point &P){ return Point(x-P.get_x(),y