title: Overloading Insertion Operator in C++
body: <p>I have a class in which I'm trying to overload the &lt;&lt; operator. For some reason, it is not being overloaded.</p>
  
  <p>Here is my .h file:</p>
  
  <pre><code>friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, const course &amp;); //course is my class object name
  </code></pre>
  
  <p>in my .cpp, I have this as my implementation:</p>
  
  <pre><code>std::ostream&amp; operator&lt;&lt;(std::ostream &amp;out, const course &amp; rhs){
      out &lt;&lt; rhs.info;
      return out;
  }
  </code></pre>
  
  <p>This should be correct, but when I try to compile it, it says that cout &lt;&lt; tmp; is not defined in ostream.</p>
  
  <p>I've included iostream in my .cpp and .h</p>
  
  <p>I'm been pulling my hair out trying to figure this out. Can you see anything that's wrong with this?</p>
  
  <p>EDIT:
  Since what I'm doing seems to be correct, here's all of my source code: <a href="http://pastebin.com/f5b523770" rel="nofollow noreferrer">http://pastebin.com/f5b523770</a></p>
  
  <p>line 46 is my prototype</p>
  
  <p>line 377 is the implementation</p>
  
  <p>line 435 is where it fails when i attempt to compile it.</p>
  
  <p>also, I just tried compiling it on another machine, and it gives this error instead: </p>
  
  <pre><code>course.cpp:246: error: non-member function 'std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, const course&amp;)' cannot have cv-qualifier
  make: *** [course.o] Error 1
  </code></pre>