title: operand order in * operator overload
body: <p>I'm writing a vec3 class for my game physics engine.</p>
  
  <p>I've made an operator overload to allow me to multiply a vector by a scalar (to scale the vector):</p>
  
  <pre><code>const vec3 operator*( const real n ) const
  {
      return vec3(
          m_x * n,
          m_y * n,
          m_z * n
      );
  }
  </code></pre>
  
  <p>This works correctly, <em>if</em> I use the correct order in my calculation:</p>
  
  <pre><code>float rImpulse;
  vec3 vContactNormal;
  ...
  vec3 vImpulse = vContactNormal * rImpulse;
  </code></pre>
  
  <p>if I change the order of multiplication (e.g. if I put the scalar first in the calculation), then compiler doesn't like this and highlights it as an error.</p>
  
  <p>Can I update my vec3 class, so that order of multiplication doesn't matter?  How?
  (I'll probably slap my forehead when I see the answer!)</p>
  
  <p><strong>Update</strong></p>
  
  <p>I've removed my original operator overload from the vec3 class and placed the following two operator overloads outside the vec3 class:</p>
  
  <pre><code>const vec3 operator*( const vec3 &amp; v, const real r )
  {
      return vec3( 
          v.x() * r, 
          v.y() * r, 
          v.z() * r 
      );
  }
  const vec3 operator*( const real n, const vec3 &amp; v )
  {
      return v * n;
  }
  </code></pre>