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?

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.