This project incorporates three exercises from the Nagler text [shown in brackets below].
To the extent that instructions here differ from the text, these instructions take precedence.
Copies of necessary files
are available in Remember to type your name and the date at the beginning of all files to be turned in. |
fraction.h
to include
all of the features listed at the top of page 286, plus two extra ctors
noted below.
int
argument for constructing a fraction that
represents a whole number: the int
is the numerator, and
1
is the denominator; and (b) one to take a C string literal
(char const *
) that can be parsed to a fraction (e.g.,
"1/2"
or "-3"
).
int
arguments - the
numerator and the denominator.
throw(char const *)
- for
(a) the converting ctor that takes a C string (in case the fraction cannot
be parsed, or if the denominator is 0); (b) the constructor that takes two
integers (in case the denominator is 0); and (c) the inversion operator
(in case it is asked to invert 0
).
friend
s. Each of operator+
and operator*
should return a Fraction const
, and
operator<<
should return an ostream &
(be sure to
#include <iosfwd>
too).
-
, +
, and !
)
each should return a new Fraction
, and be designated as const
with respect to the invoking object.
-c
option (no linking yet). If not, fix fraction.h
- do not change testfraction.cpp
.
fraction.cpp
to implement
class Fraction
. Test your implementation with testfraction.cpp
.
Insure that results exactly match the solution's results.
highest.h
to contain just
the one function template described in the exercise. Zero credit will be awarded for
this part if you write overloaded functions (for int
, double
,
and char
data) instead of the template. Test it with
testhighest.cpp. Match the solution's results.
primitive.h
as a class template.
<<
, ==
,
and +
) are most easily written as implicit inline friend
s -
see Nagler, page 365 - but you are free to choose a different way.
;
.
turnin hw5@cs60 fraction.h fraction.cpp highest.h primitive.h