Hello all!
I'm getting a "ISO C++ forbids declaration of 'ostream' with no type" error.
I'm overloading both istream and ostream operators (and get the error for both).
Here's what the code looks like:
friend ostream& operator <<( ostream& out, const term &rhs) { // if the exponent is 0, then we simply output the coeff if( rhs.exponent == 0) out<<rhs.coefficient; // if the exponent is 1, we output the coeff and x else if( rhs.exponent == 1) out<<rhs.coefficient<<"x"; // otherwise we output the coeff, x^, and it's exponent else out<<rhs.coefficient<<"x^"<<rhs.exponent;
return out; }
friend istream& operator >>( istream$ in, term &rhs) { // always get and set the coefficient in>>rhs.coefficient; // get the next character and see if it's x get( ch); if( ch == 'x') { // if it is x, get the next character and // see if it's the hat get( ch); if( ch == '^') // if it is, set the exponent from the stream in>>rhs.exponent; // otherwise put the character back and set the // exponent to 1 else { putback( ch); rhs.exponent = 1; } } // otherwise put the character back and set the // exponent to 0 else { putback( ch); rhs.exponent = 0; }
return in; }
Any help is greatly appreciated! Cheers! |