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.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.