Computer Programming (II)

Programming Assignment 5

May 3, 2005


Do Exercise 6.7 on p. 466 of the textbook. Each of the binary operations, such as addition and subtraction, should be a member function of class Rational that takes a Rational as its argument and returns a Rational. In other words, the class declaration goes like this:


class Rational {


    Rational add(Rational);

    Rational subtract(Rational);



Once you have Rational variables, x, y, and z, you can say x = y.add(z). (This can be turned into x = y + z in Chapter 8.)


The assignment is due midnight, May 13.