<p>That's basically the question, is there a "right" way to implement <code>operator&lt;&lt;</code> ?
Reading <a href="http://bytes.com/forum/thread170304.html" rel="noreferrer">this</a> I can see that something like:</p>

<pre><code>friend bool operator&lt;&lt;(obj const&amp; lhs, obj const&amp; rhs);
</code></pre>

<p>is preferred to something like </p>

<pre><code>ostream&amp; operator&lt;&lt;(obj const&amp; rhs);
</code></pre>

<p>But I can't quite see why should I use one or the other.</p>

<p>My personal case is:</p>

<pre><code>friend ostream &amp; operator&lt;&lt;(ostream &amp;os, const Paragraph&amp; p) {
    return os &lt;&lt; p.to_str();
}
</code></pre>

<p>But I could probably do:</p>

<pre><code>ostream &amp; operator&lt;&lt;(ostream &amp;os) {
    return os &lt;&lt; paragraph;
}
</code></pre>

<p>What rationale should I base this decision on?</p>

<p><em>Note</em>:</p>

<pre><code> Paragraph::to_str = (return paragraph) 
</code></pre>

<p>where paragraph's a string.</p>

You can not do it as a member function, because the implicit
```
this
```
parameter is the left hand side of the
```
<<
```
-operator. (Hence, you would need to add it as a member function to the
```
ostream
```
-class. Not good :)
Could you do it as a free function without
```
friend
```
ing it? That's what I prefer, because it makes it clear that this is an integration with
```
ostream
```
, and not a core functionality of your class.