Из http://www.learncpp.com/cpp-tutorial/142-function-template-instances/
class Cents
{
private:
int m_nCents;
public:
Cents(int nCents)
: m_nCents(nCents)
{
}
friend bool operator>(Cents &c1, Cents&c2) // <--- why friend?
{
return (c1.m_nCents > c2.m_nCents) ? true: false;
}
};
Мы также могли бы реализовать это так:
class Cents
{
private:
int m_nCents;
public:
Cents(int nCents)
: m_nCents(nCents)
{
}
bool operator> (Cents& c2) // <---
{
return (this->m_nCents > c2.m_nCents) ? true: false;
}
};
Есть ли недостатки использования второй реализации?