Add less than operator for Point2
This commit is contained in:
parent
e0cd315909
commit
a819caba8b
@ -38,6 +38,7 @@ class Point2
|
|||||||
Point2(const int x, const int y);
|
Point2(const int x, const int y);
|
||||||
bool operator==(const Point2& rhs) const;
|
bool operator==(const Point2& rhs) const;
|
||||||
bool operator!=(const Point2& rhs) const;
|
bool operator!=(const Point2& rhs) const;
|
||||||
|
bool operator<(const Point2& rhs) const;
|
||||||
Point2 operator+(const Point2& rhs) const;
|
Point2 operator+(const Point2& rhs) const;
|
||||||
Point2 operator-(const Point2& rhs) const;
|
Point2 operator-(const Point2& rhs) const;
|
||||||
Point2 operator*(const int rhs) const;
|
Point2 operator*(const int rhs) const;
|
||||||
|
@ -65,6 +65,11 @@ bool Point2::operator!=(const Point2& rhs) const
|
|||||||
return !(*this == rhs);
|
return !(*this == rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Point2::operator<(const Point2& rhs) const
|
||||||
|
{
|
||||||
|
return x < rhs.x || (x == rhs.x && y < rhs.y);
|
||||||
|
}
|
||||||
|
|
||||||
Point2 Point2::operator+(const Point2& rhs) const
|
Point2 Point2::operator+(const Point2& rhs) const
|
||||||
{
|
{
|
||||||
return Point2(x + rhs.x, y + rhs.y);
|
return Point2(x + rhs.x, y + rhs.y);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user