For this homework assignment, submit a copy of
hwkOverloadedOperators.cpp that has both the
Fraction class declaration and the definition of each function necessary to compile the file. This class stores the numerator and the denominator as
ints and has (some of) the corresponding operations that can be used on a fraction (
e.g., adding another fraction to the current object).
For full points, do not make changes to the body of the
main() function (see the
Note below).
Your copy needs to compile on
ranger using the following command-line:
g++ -std=c++0x hwkOverloadedOperators.cpp
Finally, when your code is executed, the output must match the output file
exactly:
Rubric:
Points Item
---------- --------------------------------------------------------------
_____ / 1 Fraction class declaration
_____ / 1 operator+ and operator-
_____ / 1 operator++ (prefix)
_____ / 1 operator++ (postfix)
_____ / 1 operator==, operator< and operator>
_____ / 2 operator<<
_____ / 3 operator>>
_____ / 10 Total
Notes
- Start small. In the body of the main() function, temporarily comment out everything but the object instantiations and line with the addition and assignment operators. Write the necessary (single) overloaded operator. Test it. Then, and only then, move on to the next one.
- You should verify that your output matches the above output exactly with the following commands on ranger:
g++ -std=c++0x hwkOverloadedOperators.cpp -o hwkOverloadedOperators-yourlastname
./hwkOverloadedOperators-yourlastname < /nfshome/hcarroll/public_html/3110/private/hwk/hwkOverloadedOperators-stdin1.txt &> hwkOverloadedOperators-yourlastname1.txt
diff /nfshome/hcarroll/public_html/3110/private/hwk/hwkOverloadedOperators-stdout1.txt hwkOverloadedOperators-yourlastname1.txt
./hwkOverloadedOperators-yourlastname < /nfshome/hcarroll/public_html/3110/private/hwk/hwkOverloadedOperators-stdin2.txt &> hwkOverloadedOperators-yourlastname2.txt
diff /nfshome/hcarroll/public_html/3110/private/hwk/hwkOverloadedOperators-stdout2.txt hwkOverloadedOperators-yourlastname2.txt
./hwkOverloadedOperators-yourlastname < /nfshome/hcarroll/public_html/3110/private/hwk/hwkOverloadedOperators-stdin3.txt &> hwkOverloadedOperators-yourlastname3.txt
diff /nfshome/hcarroll/public_html/3110/private/hwk/hwkOverloadedOperators-stdout3.txt hwkOverloadedOperators-yourlastname3.txt
Last Modified: