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
Expand|Select|Wrap|Line Numbers
- Fraction frac1 (3/4)
Expand|Select|Wrap|Line Numbers
- 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& );
Expand|Select|Wrap|Line Numbers
- 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