title: C++ Undefined Reference to overloaded operator
body: <p>Having a problem with my overloaded &lt;&lt; operator, cygwin is returning 2 errors,</p>
  
  <pre><code>    DeckOfCardsDemo.o:DeckOfCardsDemo.cpp:(.text+0xd3): undefined reference to `samuel::operator&lt;&lt;(std::ostream&amp;, samuel::DeckOfCards const&amp;)'
  
      DeckOfCardsDemo.o:DeckOfCardsDemo.cpp:(.text+0xd3): relocation truncated to fit: R_X86_64_PC32 against undefined symbol `samuel::operator&lt;&lt;(std::ostream&amp;, samuel::DeckOfCards const&amp;)'
  </code></pre>
  
  <p>this is my function in DeckOfCards.cpp </p>
  
  <pre><code>    std::ostream&amp; operator &lt;&lt; (std::ostream&amp; out, DeckOfCards&amp; card) 
      {
         return out &lt;&lt; card.value() &lt;&lt; " ";
      } 
  </code></pre>
  
  <p>declaration </p>
  
  <pre><code>    friend ostream&amp; operator &lt;&lt; (ostream&amp; out, const DeckOfCards&amp; card);
  </code></pre>
  
  <p>and my DeckOfCardsDemo.cpp</p>
  
  <pre><code>    #include &lt;iostream&gt;
      #include &lt;cstdlib&gt; 
      #include &lt;ctime&gt; 
      #include "DeckOfCards.h"
      using namespace std;
      using namespace samuel;
  
      int main(int argc, char* argv[]) {
  
      if (argc &gt;= 2) {
  
          int seed = atoi(argv[1]);     
      }
      else {
          int seed = time(NULL);
          srand(seed);
      }
      DeckOfCards* deck = new DeckOfCards(); //creating a deck
      cout &lt;&lt; deck-&gt;value() &lt;&lt; endl; //printing deck 
      cout &lt;&lt; *deck &lt;&lt; endl;
  
  
      return EXIT_SUCCESS;
  
  
  } 
  </code></pre>