Error: "lvalue required as left operand of assignment"
<p>I'm very much still a beginner at programming but I have come across the error "lvalue required as left operand of assignment" and I am unsure about how to resolve this issue after looking through various other discussions. The error appears in a class I made for Matrices when I overloaded certain operators. Here is part of the code,</p>

<pre><code>#ifndef MATRIX_H
#define MATRIX_H

#include &lt;iostream&gt;
#include "MVector.h"


class Matrix {
private:
vector&lt;double&gt; columns;
vector&lt;vector&lt;double&gt; &gt; A;
public:
//constructor
explicit Matrix(){};
explicit Matrix(int n,int m):columns(m),A(n,columns){};
explicit Matrix(int n,int m,double x):columns(m,x),A(n,columns){};
//destructor
~Matrix(){};
//equate matrices
Matrix &amp;operator=(const Matrix &amp;rhs) {A=rhs.A;return *this;};
//set all values to a double
Matrix &amp;operator=(double x) 
{
    int rows=this-&gt;rows();
    int cols=this-&gt;cols();
    for (int i=0;i&lt;rows;i++) 
    {
        for (int j=0;j&lt;cols;j++)
        {
            A[i][j]=x;
        }
    }
}
//access data in matrix (const)
double operator()(int i,int j) const {return A[i][j];};
//access data in matrix
double operator()(int i,int j) {return A[i][j];};
//returns the number of rows
int rows() const {return A.size();};
//returns the number of cols
int cols() const {return columns.size();};
//check if square matrix or not
bool check_if_square() const 
{
    if (rows()==cols()) return true;
    else return false;
}
};
</code></pre>

<p>and this is one of the overloaded operators which produces the error</p>

<pre><code>const Matrix operator+(const Matrix &amp;A,const Matrix &amp;B)
{
//addition of matrices
//check dimensions
if (!(A.cols()==B.cols()) || !(A.rows()==B.rows()))
{
    cout &lt;&lt; "Error: Dimensions are different \n Ref: Addition of Matrices"; 
    throw;
}
else
{
    int dim_rows = A.rows();
    int dim_cols = B.cols();
    Matrix temp_matrix(dim_rows,dim_cols);
    for (int i=0;i&lt;dim_rows;i++)
    {
        for (int j=0;j&lt;dim_cols;j++)
        {
            temp_matrix(i,j)=A(i,j) + B(i,j);
        }
    }
    return temp_matrix;
}
}
</code></pre>

<p>I assume I've done something wrong, if anyone can help and explain what I'm doing wrong that would be really appreciated. Thanks for the help!</p>
