recluse
10-19-2002, 01:49 PM
From an assignment in class I have this piece of my header file:
class rational
{
public:
rational();
rational(const int &n, const int &d);
int GetNumerator() const;
int GetDenominator() const;
bool SetValues(const int &n, const int &d);
friend ostream & operator<<(ostream &os, const rational r);
//******* COMPARISON OPERATORS *******//
friend bool operator==(const rational &r1, const rational &r2);
friend bool operator!=(const rational &r1, const rational &r2);
friend bool operator<(const rational &r1, const rational &r2);
friend bool operator>(const rational &r1, const rational &r2);
friend bool operator<=(const rational &r1, const rational &r2);
friend bool operator>=(const rational &r1, const rational &r2);
private:
void reduce();
int numerator, denominator;
};
//******* COMPARISON OPERATORS *******//
bool operator==(const rational &r1, const rational &r2);
bool operator!=(const rational &r1, const rational &r2);
bool operator<(const rational &r1, const rational &r2);
bool operator>(const rational &r1, const rational &r2);
bool operator<=(const rational &r1, const rational &r2);
bool operator>=(const rational &r1, const rational &r2);
Notice how there are two declarations for each method? My instructor said that there was a way to make it so there was on inside of the class (before }; is what I'm trying to say) by talking out the first parameter or something. I'm sorry if that was extremely confusing. Does anyone have a clue as to what I'm trying to say?
class rational
{
public:
rational();
rational(const int &n, const int &d);
int GetNumerator() const;
int GetDenominator() const;
bool SetValues(const int &n, const int &d);
friend ostream & operator<<(ostream &os, const rational r);
//******* COMPARISON OPERATORS *******//
friend bool operator==(const rational &r1, const rational &r2);
friend bool operator!=(const rational &r1, const rational &r2);
friend bool operator<(const rational &r1, const rational &r2);
friend bool operator>(const rational &r1, const rational &r2);
friend bool operator<=(const rational &r1, const rational &r2);
friend bool operator>=(const rational &r1, const rational &r2);
private:
void reduce();
int numerator, denominator;
};
//******* COMPARISON OPERATORS *******//
bool operator==(const rational &r1, const rational &r2);
bool operator!=(const rational &r1, const rational &r2);
bool operator<(const rational &r1, const rational &r2);
bool operator>(const rational &r1, const rational &r2);
bool operator<=(const rational &r1, const rational &r2);
bool operator>=(const rational &r1, const rational &r2);
Notice how there are two declarations for each method? My instructor said that there was a way to make it so there was on inside of the class (before }; is what I'm trying to say) by talking out the first parameter or something. I'm sorry if that was extremely confusing. Does anyone have a clue as to what I'm trying to say?