Tuesday, July 28, 2009

Also need the program for this with C++?

Class Rational 1 (Points: 15)


Consider the class Rational below. The class enables operation on fractions (like 1/2 or 3/4). Fractionas are reprsented by storing a numerator and a denominator as integers.





a) Add code to the class declaration to allow the overloading of the == operator. Implement as a friend operator. Be aware that the fraction 1/2 is supposed to be equal to 2/4 (ie. 1/2 == 2/4 needs to yield true).





b) Provide an implementation of the == operator.








class Rational


{


public:


Rational();


Rational(int,int);


Rational(int);


private:


int num, den;


};








Paragraph

Also need the program for this with C++?
Hint: if a/b = c/d then ad = bc (as long as b and d are non-zero)
Reply:// open your book





/* Read about classes, operators, and constructors */





/* learn something */





while (expecting_someone_to_do_your_homework_f...


{


dream_on();


}

daisy

No comments:

Post a Comment