title: How do I fix "ambiguous overload" error when overloading operator<< (templated)?
body: <p>I am trying to overload the &lt;&lt; operator, but I get the following error:</p>
  
  <blockquote>
    <p>error: ambiguous overload for 'operator&lt;&lt;' in 'std::cout &lt;&lt; "Test "'</p>
  </blockquote>
  
  <p>..Followed by 5 billion other errors similar to:</p>
  
  <blockquote>
    <p>c:\mingw\bin../lib/gcc/mingw32/4.5.2/include/c++/ostream:165:7: note:
    candidates are: ...</p>
  </blockquote>
  
  <p>This comes up because I'm using cout in my main.cpp file.  </p>
  
  <p>Here is my code:</p>
  
  <p>In BinTree.h:</p>
  
  <pre><code>    template &lt;typename T&gt;
      class BinTree{
      ...
      friend std::ostream&amp; operator&lt;&lt; &lt;&gt;(std::ostream&amp;, const T&amp;);
  </code></pre>
  
  <p>In BinTree.cpp:</p>
  
  <pre><code>    template &lt;typename T&gt;
      std::ostream&amp; operator&lt;&lt; (std:: ostream&amp; o, const T&amp; value){
          return o &lt;&lt; value;
      }
  </code></pre>
  
  <p>Thanks in advance for any help you can give.</p>