C++
Overload the following operators for the XYPoint class: ==,<, >, <=, >=, !
Semantics of these operators are based on their distance to theorigin: ie: two points are equal if their distance to the origin(0,0) is the same, one point is less than the other if its distanceto the origin is less than the other’s.
! is only true for the origin point (0,0)
Solution
#include <iostream>#include <cmath>using namespace std;class XYPoint {private: double x, y;public: double distanceToOrigin() const { return sqrt(x*x + y*y); }
OR
OR