C++ error: expected initializer before ‘&’ token
<p>the following piece of C++ code compiled two years ago in a suse 10.1 Linux machine.</p>

<pre><code>#ifndef DATA_H
#define DATA_H
#include &lt;iostream&gt;
#include &lt;iomanip&gt;


inline double sqr(double x) { return x*x; }
enum   Direction { X,Y,Z };

inline Direction next(const Direction d)
{
  switch(d)
  {
  case X: return Y;
  case Y: return Z;
  case Z: return X;
  }
}

inline ostream&amp; operator&lt;&lt;(ostream&amp; os,const Direction d)
{
  switch(d)
  {
  case X: return os &lt;&lt; "X";
  case Y: return os &lt;&lt; "Y";
  case Z: return os &lt;&lt; "Z";
  }
}
...
...
</code></pre>

<p>Now, I am trying to compile it on Ubuntu 9.10 and I get the error:</p>

<pre><code>data.h:20: error: expected initializer before ‘&amp;’ token
</code></pre>

<p>which is referred to the line of:</p>

<p>inline ostream&amp; operator&lt;&lt;(ostream&amp; os,const Direction d)</p>

<p>the g++ used on this machine is:</p>

<pre><code>Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 4.4.1-4ubuntu9' --with-bugurl=file:///usr/share/doc/gcc-4.4/README.Bugs --enable-languages=c,c++,fortran,objc,obj-c++ --prefix=/usr --enable-shared --enable-multiarch --enable-linker-build-id --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.4 --program-suffix=-4.4 --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-objc-gc --disable-werror --with-arch-32=i486 --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu9) 
</code></pre>

<p>Could you give me some hint about this error?</p>

<p>Thanks</p>

<p>P.D. If i do std::ostream, I get the errors:</p>

<pre><code>data.h:20: error: declaration of ‘operator&lt;&lt;’ as non-function
data.h:20: error: ‘ostream’ was not declared in this scope
data.h:20: error: ‘os’ was not declared in this scope
data.h:20: error: expected primary-expression before ‘const’
</code></pre>
