| <<< Binary member operator syntax | Index | Non-member binary operator syntax >>> |
// rational.h
class Rational {
//...
public:
// Unary negation, as in: x = -y
Rational operator-() const;
};
// rational.cpp
Rational Rational::operator-() const
{
// uses 2-argument constructor
return Rational( -m_n, m_d );
}
| <<< Binary member operator syntax | Index | Non-member binary operator syntax >>> |