> For the complete documentation index, see [llms.txt](https://magnum-opus.gitbook.io/c++-learning/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://magnum-opus.gitbook.io/c++-learning/class-klass-obekt-klassa/operator-peregruzka-operatorov/peregruzka-operatorov-sravneniya-greater-than-less-than.md).

# Перегрузка операторов сравнения ><

Производим перегрузку с помощью [operator](/c++-learning/class-klass-obekt-klassa/operator-peregruzka-operatorov/peregruzka-operatorov-sravneniya-greater-than-less-than.md)

В данном примере мы сравниваем оси X и Y, сравнивать можно любые поля класса в зависимости от смысла.

{% code title="Перегрузка операторов" %}

```cpp
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;
    }
}
```

{% endcode %}
