title: Multiple operands for overloaded * operator
body: <p>I want to overload the * operator for two purposes:</p>
  
  <p>First purpose:</p>
  
  <pre><code>m4 * 3.5; //m4 is a matrix object
  </code></pre>
  
  <p>The above works with this function, absolutely no problem with the implementation here</p>
  
  <pre><code>Matrix operator *(const double n)
  </code></pre>
  
  <p>However, when I attempt the reverse, i.e </p>
  
  <pre><code>3.5 * m4;
  </code></pre>
  
  <p>I get an error saying there are no matching functions. So I made this function for this particular case</p>
  
  <pre><code>Matrix operator *(const double n, Matrix &amp;obj)
  {
      for(unsigned int i = 0; i &lt; rows; i++ )
      {
          for(unsigned int j = 0; j &lt; cols; j++)
          {
              obj[i][j] =  obj[i][j] * n;
          }
  
      }
  
      return *this;
  }
  </code></pre>
  
  <p>Now, I get the error:</p>
  
  <blockquote>
    <p>error: ‘Matrix Matrix::operator*(double, Matrix&amp;)’ must take either zero or one argument
       Matrix operator *(const double n, Matrix &amp;obj);</p>
    
    <p>error: no match for ‘operator*’ (operand types are ‘double’ and
    ‘Matrix’)<br>
    cout &lt;&lt; 3.5 * m4 &lt;&lt; endl;</p>
  </blockquote>
  
  <p>I am not sure how to overcome the problem of the operands!</p>
  
  <p>Unfortunately I can't use BLAS, Eigen or the like. The assignment requires us to struggle through this matrix nonsense.</p>