title: Error LNK2005 object already defined
body: <p>I have two .cpp files:</p>
  <p>class.cpp</p>
  <pre><code>#include &quot;stdafx.h&quot;
  #include &quot;vehicles.h&quot;
  #include &lt;iostream&gt;
  #include &lt;time.h&gt;
  
  using MAP_GRID = vector&lt;vector&lt;string&gt;&gt;;
  using namespace std;
  
  void print_terrain(MAP_GRID);
  void set_position(MAP_GRID &amp;, int, int, vehicles::position, string);
  void random_position(MAP_GRID &amp;, int, string);
  MAP_GRID create_terrain();
  
  MAP_GRID MAP = create_terrain();
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      tanks t34(12, 0.5, 21,6);
      srand(time(NULL));
  
      //set_position(MAP, 5, 5, t34.pos,&quot;[x]&quot;);
      random_position(MAP, 12, &quot;[o]&quot;);
      print_terrain(MAP);
      //[...]
  }
  </code></pre>
  <p>and terrain.cpp</p>
  <pre><code>#include &quot;stdafx.h&quot;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &quot;vehicles.h&quot;
  
  #define MIN_SIZE 6
  #define MAX_SIZE 15
  
  using std::vector;
  using std::string;
  using MAP_GRID = vector&lt;vector&lt;string&gt;&gt;;
  int global_size;
  
  void set_position(MAP_GRID &amp;MAP, int x, int y, vehicles::position &amp;pos, string object)
  {
      if (x &lt;= MAP.size() || y &lt;= MAP.size())
          if (MAP[x][y] != &quot;[ ]&quot;)
              std::cout &lt;&lt; &quot;\nPosition is occupied&quot; &lt;&lt; std::endl;
          else
          {
              MAP[x][y] = object;
              pos.x.push_back(x);
              pos.y.push_back(y);
          }
              
      else
          std::cout &lt;&lt; &quot;\Choose correct position&quot; &lt;&lt; std::endl;
  }
  //[...]
  </code></pre>
  <p>and also header file:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  using std::vector;
  
  using MAP_GRID = vector&lt;vector&lt;string&gt;&gt;;
  void change_position(MAP_GRID &amp;, int, int);
  
  class vehicles{
  protected:
      double durability;
      double velocity;
  public:
       vehicles(double d, double v) : durability(d), velocity(v) {}
       ~vehicles() {}
  
       void drive();
       void info() { cout &lt;&lt; durability &lt;&lt; &quot; &quot; &lt;&lt; velocity &lt;&lt; &quot;\n&quot;; }
  
       struct position{
           vector&lt;int&gt; x;
           vector&lt;int&gt; y;
       }pos;
  
      
  };
  
  class tanks:public vehicles{
  private:
      double damage;
  public:
      tanks(double dmg, double v, double d, int m) :vehicles(d, v), damage(dmg), ammo(m) {}
      ~tanks() {}
      int ammo;
      void shoot();
      void info();
  };
  
  void tanks::shoot(){
      if (ammo &gt;= 0)
      {
          cout &lt;&lt; &quot;You deal &quot; &lt;&lt; damage &lt;&lt; &quot;. You have &quot; &lt;&lt; ammo &lt;&lt; &quot;ammo left.\n\n&quot;;
          ammo-=1;
      }
      else
          cout &lt;&lt; &quot;You don't have ammo\n\n&quot;;
  }
  
  void tanks::info(){
      cout &lt;&lt; &quot;You velocity &quot; &lt;&lt; velocity &lt;&lt; endl;
      cout &lt;&lt; &quot;You durability &quot; &lt;&lt; durability &lt;&lt; endl;
      cout &lt;&lt; &quot;You damage &quot; &lt;&lt; damage &lt;&lt; endl;
  }
  </code></pre>
  <p>The compiler (Microsoft Visual Studio 2013) gives me these errors:</p>
  <pre><code>terrain.obj : error LNK2005: &quot;public: void __thiscall tanks::info(void)&quot; (?info@tanks@@QAEXXZ) already defined in class.obj
  terrain.obj : error LNK2005: &quot;public: void __thiscall tanks::shoot(void)&quot; (?shoot@tanks@@QAEXXZ) already defined in class.obj
  class.exe : fatal error LNK1169: one or more multiply defined symbols found
  </code></pre>
  <p><img src="https://i.stack.imgur.com/Pdpve.png" alt="errors" /></p>
  <p>I know it's a common question about this error, but I'm trying remove it, without success.</p>