I recently wrote a matrix class and overloaded the '()' operator for easy access to the elements. I return the address of the selected element for easy modification.
Then I also thought that you might wanna make the element read-only, anyway this was my solution :
I get a warning when I compile (returning address of local variable...) but I don't know if this would be bad/dangerous in this particular case.
double & CMatrix::operator () (int row, int col)
//Err check omitted
double tempVal = elements[row][col];
Is this a bad way to do it in this case ? If so why, and what would be a better solution ?