title: Visual Studio 2010 Linker Finding Multiply Defined Symbols (Where It Shouldn't)
body: <p>I've just started with C++, and maybe there's something that I'm doing wrong here, but I'm at a loss. When I try to build the solution, I get 4 <code>LNK2005</code> errors like this one:</p>
  
  <p><code>error LNK2005: "public: double __thiscall Point::GetX(void)const " (?GetX@Point@@QBENXZ) already defined in CppSandbox.obj</code></p>
  
  <p>(there's one for each get/set method, and they all allegedly occur in <code>Point.obj</code>)</p>
  
  <p>And then finally this error:</p>
  
  <p><code>error LNK1169: one or more multiply defined symbols found</code></p>
  
  <p>Which reportedly occurs in <code>CppSandbox.exe</code>. I'm not sure what causes this error - it appears to happen when I build or rebuild the solution... Really at a loss, to be honest.</p>
  
  <p>The three files below are the entirety of what I added to the default VS2010 blank project (they're copied in their entirety). Thanks for any help you can offer.</p>
  
  <p><strong>Point.h</strong></p>
  
  <pre><code>class Point
  {
  public:
      Point() 
      { 
          x = 0; 
          y = 0; 
      };
      Point(double xv, double yv) 
      { 
          x = xv;
          y = yv; 
      };
  
      double GetX() const;
      void SetX(double nval);
  
      double GetY() const;
      void SetY(double nval);
  
      bool operator==(const Point &amp;other)
      {
          return GetX() == other.GetX() &amp;&amp; GetY() == other.GetY();
      }
  
      bool operator!=(const Point &amp;other)
      {
          return !(*this == other);
      }
  
  private:
      double x;
      double y;
  };
  </code></pre>
  
  <p><strong>Point.cpp</strong></p>
  
  <pre><code>#include "Point.h"
  
  double Point::GetX() const
  {
      return x;
  }
  
  double Point::GetY() const
  {
      return y;
  }
  
  void Point::SetX(double nv)
  {
      x = nv;
  }
  
  void Point::SetY(double nv)
  {
      y = nv;
  }
  </code></pre>
  
  <p><strong>CppSandbox.cpp</strong></p>
  
  <pre><code>// CppSandbox.cpp : Defines the entry point for the console application.
  //
  
  #include "stdafx.h"
  #include &lt;iostream&gt;
  #include "Point.cpp"
  
  int main()
  {
      Point p(1, 2);
      Point q(1, 2);
      Point r(2, 3);
  
      if (p == q) std::cout &lt;&lt; "P == Q";
      if (q == p) std::cout &lt;&lt; "Equality is commutative";
      if (p == r || q == r) std::cout &lt;&lt; "Equality is broken";
  
      return 0;
  }
  </code></pre>