title: C++ Header and CPP includes
body: <p>quick question.</p>
  
  <p>I am trying to get C++ nailed down, and today I spent hours with a double definition linker error("this has already been defined!") and I finally realised it's because I had the layout as such:</p>
  
  <ul>
  <li><p>main.cpp</p>
  
  <pre><code>#include Dog.cpp
  </code></pre></li>
  <li><p>Dog.cpp</p>
  
  <pre><code>#include Dog.h
  </code></pre></li>
  <li><p>Dog.h</p>
  
  <pre><code>// (Dog class and prototype of test function)
  </code></pre></li>
  </ul>
  
  <p>And now that I've cleared that up by including the Dog.h instead of the Dog.cpp in the main.cpp.</p>
  
  <p><strong>By including the .h file, does the .cpp file with the identical prefix get compiled with the program?</strong></p>
  
  <p>I was astounded when the program ran with only the .h included and no references whatsoever to Dog.cpp. I spent ages Googling but no answers really helped me understand what was going on.</p>
  
  <p><strong>Edit</strong>: I forgot to add that I prototyped in the .h, and defined the function for the class in the .cpp and that's what gave me the "already defined" error.</p>