Erratic declaration behavior: Rational.h:25: error: expected constructor, destructor, or type conversion before ‘&’ token
<p>so, I have been having issues in this header file overloading the stream insertion operator. I receive the error message in the title if I use the code as is. But when I put the declaration in the main file, it works fine.</p>

<p>Rational.h</p>

<pre><code>#ifndef RATIONAL_H
#define RATIONAL_H

using namespace std;
class Rational{
private:
    int numerator;
    unsigned int denominator;
    bool isNegative;

public:
    Rational();
    Rational(int);
    Rational(int, int);

    bool operator==(const Rational&amp;);
    Rational&amp; operator++(int);          //Unused int
    Rational operator-(const Rational&amp;);
    Rational operator+(const Rational&amp;);
    Rational operator*(const Rational&amp;);
    Rational operator/(const Rational&amp;);
};

ostream&amp; operator&lt;&lt;(ostream&amp;, Rational&amp;); //Erroneous code


#endif
</code></pre>

<p>The other two files, 1.c and Rational.c if needed:</p>

<pre><code>#include "Rational.h"
#include &lt;iostream&gt;
#include &lt;math.h&gt;

using namespace std;

Rational::Rational(){
numerator   = 0;
denominator = 1;
}

Rational::Rational(int num){
numerator   = num;
denominator = 1;     
}

Rational::Rational(int num, int den){
//Determine negativity
if(num &lt; 0 xor den &lt; 0){    //If negative
    if(num &gt; 0){
        num *= -1;
    }
}

numerator   = num;
denominator = abs(den);  
}

bool Rational::operator==(const Rational&amp; rhs){
return (numerator/(double)denominator == rhs.numerator/(double)(rhs.denominator));
}

ostream&amp; operator&lt;&lt;(ostream&amp; os, Rational&amp; input){
os &lt;&lt; "Moo";
return os;
}
/*
private:
    int  numerator;
    unsigned int  denominator;
    bool isNegative;

public:
    Rational(int, int);

    bool operator==(const Rational&amp;);
    Rational&amp; operator++(int);          //Unused int
    Rational operator-(const Rational&amp;);
    Rational operator+(const Rational&amp;);
    Rational operator*(const Rational&amp;);
    Rational operator/(const Rational&amp;);
*/
</code></pre>

<p>1.c</p>

<pre><code>#include &lt;iostream&gt;
#include "Rational.h"

using namespace std;

int main(){
Rational test = Rational(2);

cout &lt;&lt; test &lt;&lt; endl;
}
</code></pre>
