Open alexey-malov opened 7 years ago
CRational const operator +() const;
CRational const operator -();
[x] оператор - должен быть константным, т.к. унарный минус не изменяет значение своего аргумента
[x] Почему унарные операторы + и - возвращают константное значение?
int x;
CRational y;
...
auto z = x + y; // ожидается, что z - рациональное число
if (z < 3) // вместо if (z < CRational(3))
{
}
//////////////////////////////////////////////////////////////////////////
// TODO: 11. Реализовать операторы == и !=
//////////////////////////////////////////////////////////////////////////
bool const operator ==(CRational const& first, CRational const& second)
{
return true;/* (first.GetNumerator() == second.GetNumerator()) &&
(first.GetDenominator() == second.GetDenominator());*/
}
bool const operator !=(CRational const& first, CRational const& second)
{
return true; /*(first.GetNumerator() != second.GetNumerator()) ||
(first.GetDenominator() != second.GetDenominator());*/
}
//////////////////////////////////////////////////////////////////////////
// TODO: 12. Реализовать операторы <, >, <=, >=
//////////////////////////////////////////////////////////////////////////
bool const operator <(CRational const& first, CRational const& second)
{
return true;// ((first.GetNumerator() * second.GetDenominator()) < (first.GetDenominator() * second.GetNumerator()));
}
bool const operator >(CRational const& first, CRational const& second)
{
return true; /*((first.GetNumerator() * second.GetDenominator()) > (first.GetDenominator() * second.GetNumerator()));*/
}
bool const operator <=(CRational const& first, CRational const& second)
{
return true;/* !(first > second);*/
}
bool const operator >=(CRational const& first, CRational const& second)
{
return true;/* !(first < second);*/
}