title: operator overloading outside of a class!
body: <p>when i was trying to seperate the declaration and implementation of a non-member overloaded operator, i got a LNK2001 error in VC2010, my code was like this:</p>
  
  <p>-foo.h-</p>
  
  <pre><code>class A
  {
  public:
      A(float x);
      float x;
  };
  A operator +(const A&amp;, const A&amp;);
  </code></pre>
  
  <p>-foo.cpp-</p>
  
  <pre><code>A::A(float x)
  {
      this-&gt;x = x;
  }
  
  A operator +(const A&amp; lh, const A&amp; rh)
  {
      return A(lh.x + rh.x);
  }
  </code></pre>
  
  <p>so once i use the '+' operation, the error pumps out, but if i remove the declaration in the header file, there are no LNK2001 errors.. i cannot figure out why..</p>