title: Undefined reference for function accepting references to user defined classes
body: <p>I have a problem with a function that accepts as input references to two user defined objects. Here's what it looks like:</p>
  
  <pre><code>void copy_job_list( vector&lt;Job&gt; &amp;org, vector&lt;Job&gt; &amp;dest)  
  {  
        // ....  
  }
  </code></pre>
  
  <p>The function is defined in file <code>functions.cpp</code>, and called in <code>job_random.cpp</code>, both files include the header in which the declaration of this function is given.</p>
  
  <p>Now when in <code>job_random.cpp</code> I call the function with </p>
  
  <pre><code>copy_job_list( Old_best_list.J, Old_best_list_new_times.J) ;  
  </code></pre>
  
  <p>where <code>Old.best_list.J</code> and <code>Old_best_list_new_times.J</code> are vectors of type <code>Job</code>, I get the following error with g++:</p>
  
  <pre><code>job_random.o:job_random.cpp:(.text+0x1fc): undefined reference to 
  `copy_job_list(std::vector&lt;Job, std::allocator&lt;Job&gt; &gt;, 
                             std::vector&lt;Job, std::allocator&lt;Job&gt; &gt;&amp;)'
  collect2: ld returned 1 exit status
  mingw32-make: *** [random_job] Error 1
  </code></pre>
  
  <p>This looks like linker is convinced only second argument should be a reference, and first should be a value. And indeed if I change definition and declaration of copy_job_list() so that first argument is passed by value, then program compiles. But why would linker insist I do that?</p>
  
  <p>From what I was able to find on the web it seems like undefined reference messages usually mean I didn't include headers the right way or such, but <code>functions.cpp</code> contains a multitude of other functions that <code>job_random.cpp</code> uses without a hitch, all of them declared through a common header.</p>