
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The requirements for program 6 in csci 152, where students are tasked with rewriting arithmetic and comparison methods as overloaded operators for a fraction class. The document also includes instructions for changing the fraction.h declarations and implementations in fraction.cpp, as well as rewriting the fractiontestdriver. An extra credit opportunity is provided for removing the print() member function and overloading the stream insertion operator instead.
Typology: Exams
1 / 1
This page cannot be seen from the preview
Don't miss anything!

CSCI 152 Program 6 Spring 2005 Due: Friday, 6 May
Emphasis on: Overloading Operator Functions
For program 6, you are to revisit program 5 where we created a Fraction class. The fraction class contained methods for performing arithmetic operations such as add, sub, mult and div. The fraction class also contained comparison operators such as equal, greaterthan and lessthan. For program 6, you are to rewrite these methods as overloaded operator methods. Change the definition of Fraction.h to user overloaded operators and also change implementations of these member funcitons in Fraction.cpp to reflect the changes. You should also rewrite the FractionTestDriver to demonstrate the use of the overloaded operators on the Fraction class.
Program 6 Requirements:
Extra Credit:
The print class method, as written in program 5, writes a representation of the fraction on cout standard output stream. It is conventional not to have classes send output directly to streams, but leave input and output up to the client/user program. For 10 extra credit points, remove the print() member function and instead provide and overloaded << (insertion) member function that will insert a representation of the fraction into a stream. Se the book chapter 15, pg 822 for an example of overloading the stream insertion operator.