I am trying to use operator+ overloading to add to matrices classes. It is on the line rslt = m1+m2 where rslt, m1, m2 are alll matrix classes.
Here is the code:
int main(int argc,char *argv[])
{
matrix rslt;
matrix m1;
m1.initMatrix(10,10,5,1);
m1.print();
matrix m2;
m2.initMatrix(10,10,10,2);
m2.print();
// this works
m1 = m2;
// gives error here
rslt = m1+m2;
}
matrix matrix::operator=(const matrix & rhs)
{
int iter = rhs.getIterations();
this.setIteations(iter);
return *this;
}
matrix matrix::operator+(const matrix & b)
{
int ** result;
int rows = this.getRowSize();
int cols = this.getColSize();
int seed = this.getSeed();
Yes kind of. int ** result and int**m are defined to be 2d matricies in class matrix.
I am not using rslt. I am using 'm' to stroe the data after addition.
m1, m2, rslt are instances of class matrix, on which the operation rslt=m1+m2 gives error.
This is the class definition:
class matrix
{
......
......
int **m;
int **result;
matrix matrix::operator+(const matrix & rhs);
........
....
}