title: c++ multiple definition error for every constructor, method, and operator overload
body: <p><em>I realize that there are a lot of "multiple definition" questions out here already, but I've spent the past 2 hours looking for an explanation and haven't found one. So sorry if this is a duplicate.</em></p>
  
  <p>Right now I have 2 classes: Array.h and Vector.h. Neither has any global variables, and neither is dependent on the other (i.e. Array doesn't use Vector and Vector doesn't use Array). The implementations are in the .h files.</p>
  
  <p>Here's my Main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include "Array.h"
  #include "Vector.h"
  using namespace std;
  
  int main() {
      cout &lt;&lt; "Done" &lt;&lt; endl;
  
      return 0;
  }
  </code></pre>
  
  <p>...and everything runs fine. However, when I create another .cpp file with only #include statements...</p>
  
  <p>DataReader.cpp</p>
  
  <pre><code>#include "Array.h"
  #include "Vector.h"
  </code></pre>
  
  <p>...then everything blows up and I get a whole slew of errors for every method, constructor, and operator overload in Vector:</p>
  
  <pre><code>DataReader.o: In function `Vector':
  C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:49: multiple definition of `Vector::Vector()'
  TestMain.o:C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:49: first defined here
  DataReader.o: In function `Vector':
  C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:53: multiple definition of `Vector::Vector(int const&amp;, int const&amp;, int const&amp;)'
  TestMain.o:C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:53: first defined here
  DataReader.o: In function `Vector':
  C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:56: multiple definition of `Vector::Vector(double const&amp;, double const&amp;, double const&amp;)'
  TestMain.o:C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:56: first defined here
  DataReader.o: In function `ZNK6Vector1xEv':
  C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:59: multiple definition of `Vector::x() const'
  TestMain.o:C:\C++\Eclipse CDT\workspace\3D_Adaptive_FEM\Debug/..//Vector.h:59: first defined here
  
  etc...
  </code></pre>
  
  <p>But if I just have <code>#include "Array.h"</code> in DataReader.cpp, then everything runs fine!</p>
  
  <p>What can possibly be wrong with <code>#include "Vector.h"</code> that doesn't apply to <code>#include "Array.h"</code>?</p>
  
  <p>Edit:
  Separating the implementations into .cpp files fixes the errors, but that doesn't explain why I have to do it for Vector and not Array.</p>