inherit/rftest4.cpp

The following code example is taken from the book
Object-Oriented Programming in C++
by Nicolai M. Josuttis, Wiley, 2002
© Copyright Nicolai M. Josuttis 2002


// header files
#include <iostream>
#include "rfrac.hpp"

int main()
{
    // declare RFraction
    CPPBook::RFraction x(7,3);

    /* multiply x by 3
     * BUT: use operator of the base class fraction
     */
    x.CPPBook::Fraction::operator *= (3);

    // output x
    std::cout << x;
    std::cout << (x.isReducible() ? " (reducible)"
                                  : " (non reducible)") << std::endl;
}