I am trying to create a function which adds an array to another array and replaces the data in the 1st array with the new data. For example, A=A+B. However, when I write my code as below, I get the error C2676:binary '[' : 'const Matrix' does not define this operator or a conversion to a type acceptable to the predefined operator.

void Matrix::add(const Matrix&m){
    for(int i=0; i<9; i++){
        data[i]=data[i]+m[i];
    }
}

Thanks in advanced for the help!

Most likely what you wanted was this:

data[i] = data[i] + m.data[i];

Since the error suggests you don't overload the subscript operator to get the contents of data, you need to touch m's copy of data directly.