title: What is the benefit to using a static library over including a header file?
body: <p>Sorry if this is a noobish question, but here it is anyway.</p>
  
  <p>So I followed <a href="https://msdn.microsoft.com/en-us/library/ms235627.aspx" rel="nofollow">this tutorial</a> on MSDN about creating and using static libraries.</p>
  
  <p>Let's assume you have a Static Library <code>fooLib</code>, and a Program <code>barExec</code>, that uses <code>fooLib</code></p>
  
  <p>According to the tutorial, or at least my interpretation of it, in the source code for <code>barExec</code>, you have to <code>#include</code> the header file used to compile <code>fooLib</code> (<code>fooLib.h</code>, in my case).</p>
  
  <p>So the code that I have in <code>barExec</code> is as follows:</p>
  
  <pre><code>// barExec.cpp
  
  #include &lt;iostream&gt;
  #include "fooLib.h"
  
  // Rest of my program here.
  </code></pre>
  
  <p>My question is, Why should I bother going through all the extra hassle of creating <code>fooLib</code> in the first place, especially since I had to write <code>fooLib.cpp</code> anyway? Is there a benefit to creating the <code>fooLib</code> library, when I could just <code>#include "fooLib.h"</code> directly?</p>