How can I sum two complex matrix in C++?

  add, c++, matrix, oop, sum

I have a class for complex numbers whose data members are im (the imaginary part) and re (the real part). Now I want to sum 2 matrix that come from the class Matrix (A and B) and put the sum in another matrix (C). This is what I tried. Any advice?
Edit: the error is "no match for ‘operator[]’ (operand types are ‘Matrix’ and ‘int)
”’inline Matrix& operator+(Matrix& A, Matrix& B)
{

    Matrix *C = new Matrix;
    C->rows = A.rows;
    C->columns = A.columns;
    for(int i = 0; i <  A.rows; i++)
        for(int j = 0; j <  A.columns; j++)
            C[i][j] = A[i][j] + B[i][j];
}
return **C;

}

Source: Windows Questions C++

LEAVE A COMMENT