title: How to properly overload the << operator?
body: <p>I am writing my own integer class that can handle integers of any size. So far, I have overloaded the following operators successfully:  =, +, -, *, /, %, >, &lt;, >=, &lt;=, ==, !=, +=, -=, *=, /=, and %=.</p>
  
  <p>Now, I'm trying to overload the <code>&lt;&lt;</code> operator to mimic the behavior of int's in the following lines of code:</p>
  
  <pre><code>int a = 5;
  std::cout &lt;&lt; a;
  </code></pre>
  
  <p>I have been looking at how to do this for a while, and so far all I've found is this:</p>
  
  <pre><code>std::ostream&amp; operator&lt;&lt;(std::ostream&amp; os, const T&amp; obj)
  {
    // Write obj to stream
    return os;
  }
  </code></pre>
  
  <p>But this seems to be for if I wanted to stream something into my object (that is, having the <code>&lt;&lt;</code> on the right side of my object). But I want to change the behavior of <code>&lt;&lt;</code> when it is on the LEFT side of my object.</p>
  
  <p>How can I set up the <code>operator&lt;&lt;</code> function to allow me to stream data into cout (or any other <code>ostream</code>)?</p>