0

I am getting this error when trying to compile my program the code part I am getting this error is:

matrixType MatrixADT::add(matrixType M1, matrixType M2){
    matrixType M;
    for(int i=0;i<M1.matDimension;i++){
        for(int j=0;j<M2.matDimension;j++){
            M.matDimension[i][j] = M1.matDimension[i][j] + M2.matDimension[i][j];//Here is the error
        }
    }
    return M;
}

Complete code can be viewed here.

I have googled for this and found several questions with the same but cant figure out whats the problem.

1
  • Why is this tagged c? Why are you passing your arguments by value? And... what is the error? Commented Apr 13, 2014 at 10:10

1 Answer 1

1

Based on the definition of matrixType:

struct matrixType{
    int matDimension;
    int matValues[10][10];
};

You need to change

M.matDimension[i][j] = M1.matDimension[i][j] + M2.matDimension[i][j];

to

M.matValues[i][j] = M1.matValues[i][j] + M2.matValues[i][j];
Sign up to request clarification or add additional context in comments.

2 Comments

Oops!! How fool was I any ways Thanks a lot for your help.
If this answer solved your problem, please accept it as solution. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.