cannot bind 'std::basic_ostream' lvalue to 'std::basic_ostream<char>&&'
<p>I define in a class A an &lt;&lt; operator like this :
A.h :</p>

<pre><code>class API_name A {
    friend API_name std::ostream&amp; operator&lt;&lt;(std::ostream&amp; o, const A&amp;a);
}
</code></pre>

<p>A.cpp :</p>

<pre><code>ostream&amp; operator&lt;&lt;(ostream&amp; o, const A&amp; a);
</code></pre>

<p>In another file including A.h, I want to do this :</p>

<pre><code>void fonction(const A* a) {
    std::cout &lt;&lt; "a contains : " &lt;&lt; *a &lt;&lt; std::endl;
}
</code></pre>

<p>At this line, I gcc returns the following error :</p>

<p>error: cannot bind 'std::basic_ostream' lvalue to 'std::basic_ostream&amp;&amp;'</p>

<p>Can someone tell me why and how to avoid this compilation error?</p>