В данном примере мы сравниваем оси X и Y, сравнивать можно любые поля класса в зависимости от смысла.
bool operator >(const coordinate &other) // перегрузка >
{
if (this->x > other.x && this->y > other.y)
{
return true;
}
else
{
return false;
}
}
bool operator <(const coordinate& other) // перегрузка <
{
if (this->x < other.x && this->y < other.y)
{
return true;
}
else
{
return false;
}
}