title: Operator overloading outside class
body: <p>There are two ways to overload operators for a C++ class:</p>
  
  <h3>Inside class</h3>
  
  <pre><code>class Vector2
  {
  public:
      float x, y ;
  
      Vector2 operator+( const Vector2 &amp; other )
      {
          Vector2 ans ;
          ans.x = x + other.x ;
          ans.y = y + other.y ;
          return ans ;
      }
  } ;
  </code></pre>
  
  <h3>Outside class</h3>
  
  <pre><code>class Vector2
  {
  public:
      float x, y ;
  } ;
  
  Vector2 operator+( const Vector2&amp; v1, const Vector2&amp; v2 )
  {
      Vector2 ans ;
      ans.x = v1.x + v2.x ;
      ans.y = v1.y + v2.y ;
      return ans ;
  }
  </code></pre>
  
  <p>(Apparently in C# you can only use the "outside class" method.)</p>
  
  <p>In C++, which way is more correct?  Which is preferable?</p>