Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

class Rational { public: Rational(int num, int den); Rational(int whole_number);

ID: 3550986 • Letter: C

Question

class Rational
{
public:
Rational(int num, int den);
Rational(int whole_number);
Rational();

friend istream& operator>> (istream&, Rational &);
friend ostream& operator<< (ostream&, Rational &);

friend bool operator == (const Rational&, const Rational&);

friend bool operator < (const Rational&, const Rational&);

friend bool operator <= (const Rational&, const Rational&);

friend bool operator > (const Rational&, const Rational&);

friend bool operator >= (const Rational&, const Rational&);

friend Rational operator + (const Rational&, const Rational&);

friend Rational operator - (const Rational&, const Rational&);

friend Rational operator * (const Rational&, const Rational&);

friend Rational operator / (const Rational& , const Rational&);


private:
int numerator;
int denominator;

};


1>f:csc330 ew folderS.cpp(8) : error C2143: syntax error : missing ';' before '&'
1>f:csc330 ew folderS.cpp(8) : error C2433: 'istream' : 'friend' not permitted on data declarations
1>f:csc330 ew folderS.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>f:csc330 ew folderS.cpp(8) : error C2061: syntax error : identifier 'istream'
1>f:csc330 ew folderS.cpp(8) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>f:csc330 ew folderS.cpp(8) : error C2805: binary 'operator >>' has too few parameters
1>f:csc330 ew folderS.cpp(9) : error C2143: syntax error : missing ';' before '&'
1>f:csc330 ew folderS.cpp(9) : error C2433: 'Ostream' : 'friend' not permitted on data declarations
1>f:csc330 ew folderS.cpp(9) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>f:csc330 ew folderS.cpp(9) : error C2061: syntax error : identifier 'ostream'




why???? please help!~




Explanation / Answer

Try replacing ostream and istream with std::ostream and std::istream.