this is what I made for a = operator:

matrix matrix::operator= (double a[]) 
  for (int i = 0; i < rows * clms; i++){
    //std::cout << i<< "=" <<a[i] << " ";
    *(x +i) = a[i];
    //std::cout << i<< "=" <<x[i] << " ";
  return *this;

and I try to use it with this

matrix m(3);
double a[12] = { 16,2,3,13,5,11,10,8,9,7,6,12};
m = a;

but if you try it you will see that it only changes the value for the scope of the = operator function. Any ideas?

7 Years
Discussion Span
Last Post by qwertymk

Ok this is weird. I just took my flash drive that I was working on to another computer using the same compiler (dev-cpp) and it did work. Any ideas on why that is?


This is really humiliating. Basically what I had was

matrix matrix::operator= (double a[])

what I needed was

matrix &matrix::operator= (double a[])

by not passing it by reference (matrix::operator and not &matrix::operator) I assume it just made a copy and that was what I was changing

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.