title: Overloading "+" operator for matrices C++
body: <p>Here is a simplified addition operator overload for matrices that I've wrote, but my IDE (Clion) does not recognise it when I'm trying to use it like this: <code>m1 = m2 + m3</code>, and says: "binary operator + can't be applied to the expressions of type 'Matrix' and 'Matrix' "</p>
  
  <pre class="lang-cpp prettyprint-override"><code>Matrix&amp; Matrix::operator += (Matrix&amp; m1)
  {
      for (int i = 0; i &lt; m_rows; ++i)
          for (int j = 0; j &lt; m_cols; ++j)
              m_matrix[i][j] += m1.m_matrix[i][j];
      return *this;
  }
  
  Matrix&amp; operator + (Matrix m1, Matrix&amp; m2){ return m1+=m2; }
  </code></pre>
  
  <p>What do I have to fix here?</p>
  
  <p>P.S. I have also defined custom copy and move constructors and an assignment operator: </p>
  
  <pre><code>Matrix::Matrix(const Matrix&amp; m1)
      : m_matrix{new double*[m1.rows()]},
        m_rows{m1.rows()},
        m_cols{m1.cols()}
  {
      for (int i = 0; i &lt; m1.rows(); ++i) {
          m_matrix[i] = new double[m1.cols()];
          for (int j = 0; j &lt; m1.cols(); ++j)
              m_matrix[i][j] = m1.m_matrix[i][j];
      }
  }
  
  Matrix&amp; Matrix::operator = (const Matrix&amp; m1){
      Matrix matrix(m1.rows(), m1.cols());
  
      for (int i = 0; i &lt; m1.rows(); ++i)
          for (int j = 0; j &lt; m1.cols(); ++j)
              matrix.m_matrix[i][j] = m1.m_matrix[i][j];
  
      for (int i = 0; i &lt; m_rows; ++i)
          delete m_matrix[i];
      delete m_matrix;
  
      m_matrix = matrix.m_matrix;
      m_rows = m1.rows();
      m_cols = m1.cols();
  
      return *this;
  }
  
  Matrix::Matrix(Matrix&amp;&amp; m1) noexcept
      : m_matrix{m1.m_matrix},
        m_rows{m1.m_rows},
        m_cols{m1.m_cols}
  {
      for (int i = 0; i &lt; m1.m_rows; ++i)
          delete m1.m_matrix[i];
      delete m1.m_matrix;
      m1.m_rows = m1.m_cols = 0;
  }
  </code></pre>