dynamic assignment operator problems vs2012

hi there,

I'm wondering if someone could shed some light on this issue I'm having. I upgraded to vs2012 and a library that used to work is having issues.


I have three private class member (long col_,long row_, double *matrix), and this is what the assignment operator looks like.

1
2
3
4
5
6
7
8
9
10
11
Matrix & Matrix::operator=(const Matrix & mat) {
if (this == &mat) return *this;

row_ = mat.row();
col_ = mat.col();
delete [] matrix;
double *matrix = new double[row_*col_];
for (long it = 0; it < row_*col_; it++)
    matrix[it] = mat.matrix[it];
return *this;
}


While debugging I have noticed it is not taking *matrix as the class object which is very odd (the address of the (*this).matrix and matrix are different) Does anyone know what could be causing this issue. Or how I could remedy this? I thought this was a fairly standard assignment operator?
It looks likes you're declaring a local variable called "matrix" on line 7. This will hide the member variable.

Andy

Last edited on
you seem to be absolutely correct, that's very odd that that ended up in there.

thanks for the help!

Iain
Topic archived. No new replies allowed.