we're given an implementation file to base our class of Fraction off of.
Input and output are in the format x/y, with x and y being ints, with the "/" character in the middle.
so to create an object of class Fraction, it'd need to be like
however I'm not sure on how to create this fraction with the format of the .h file we're given
I guess what's tripping me up is the format it's sent in, with the "/" character. if it was
i'd have no problem.
If someone could tell me at least how to declare the fraction to be passed around to the other objects, everything else should fall into place
Thanks Much,
-Myxamatosis
Input and output are in the format x/y, with x and y being ints, with the "/" character in the middle.
so to create an object of class Fraction, it'd need to be like
Code:
Fraction frac1 (3/4)
Code:
class Fraction
{
public:
// Construct fraction from numerator and denominator
//
Fraction( int = 0, int = 1 );
// Construct fraction by copying existing fraction
//
Fraction( const Fraction& );
// Assign into fraction by copying existing fraction
//
Fraction& operator=( const Fraction& );
// Return true if fraction is valid (non-zero denominator)
//
bool IsValid() const;
// Return value of numerator
//
int Numerator() const;
// Return value of denominator
//
int Denominator() const;
// Input/Output operations
//
friend istream& operator>>( istream&, Fraction& );
friend ostream& operator<<( ostream&, const Fraction& );
Code:
Fraction fract1 ( 3,4);
If someone could tell me at least how to declare the fraction to be passed around to the other objects, everything else should fall into place
Thanks Much,
-Myxamatosis
Comment