title: How does C++ linker know what .cpp files to use
body: <p><strong>I am a C++ learner and I came across a concept of separating code into multiple files to speed up compiling process on bigger projects.</strong> </p>
  
  <p>However what the book doesn't tell me and I have tried to find it in other books and on the web, but with no luck is how does linker (during compilation) knows what files to include.</p>
  
  <p>When I make new file I connect its header to the main file with <code>#include "newfile.h"</code>, however in this header I don't write where to find definitions of functions. </p>
  
  <p>So how I imagine the process is that it starts in the main file and there it finds "connections" to other files. The question is how it finds those .cpp files that as far as I see don't need to be named the same as its header file.</p>
  
  <p><strong>Exmple:</strong></p>
  
  <p>Main file:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "krneki_H.h"
  
  using namespace std;
  
  
  int main()
  {
   krneki1();
   krneki2();
   krneki3();
  }
  </code></pre>
  
  <p><strong>And header file:</strong></p>
  
  <pre><code>void krneki1();
  void krneki2();
  void krneki3();
  </code></pre>
  
  <p><strong>And new .cpp file:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "krneki_H.h"
  
  using namespace std;
  
  void krneki1() {
  cout&lt;&lt;"Krneki1"&lt;&lt;endl;}
  
  void krneki2() {
  cout&lt;&lt;"Krneki2"&lt;&lt;endl;}
  
  void krneki3() {
  cout&lt;&lt;"Krneki3"&lt;&lt;endl;}
  </code></pre>
  
  <p><strong>Notice that there is no indication to use second cpp file. It just knows to use it. Does it search all .cpp files in the map?</strong></p>
  
  <p>Thank you for answer.</p>