Logo Search packages:      
Sourcecode: kbruch version File versions  Download package

ratio ratio::operator+ ( ratio  addend )

operator overloading for: c = object + summand

Definition at line 162 of file ratio.cpp.

References denominator(), m_denominator, m_numerator, numerator(), reduce(), setDenominator(), and setNumerator().

Referenced by operator-().

    // this object will be returned as the sum
    ratio sum (0, 1);

    // calculate and set the numerator without reducing
    sum.setNumerator (m_numerator * addend.denominator()
                      + addend.numerator() * m_denominator, false);

    // calculate and set the denominator without reducing
    sum.setDenominator (m_denominator * addend.denominator(), false);

    // reduce the sum

    return sum;

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index