Hello. Following is a code in which I have implemented matrices using classes and then added several functions into the class, such as that of addition and subtraction... To me, the code looks ok and it works fine as well until the input function..
However, it started giving error when I tried to call addition function (while accessing the data from the matrices)... I added a copy constructor, hence and that solved the problem.
But then, when I called the display function for the new matrix, which I made for the result of the addition function, it again gave the same runtime error when it tried to access the object's data.. Can anyone tell me what's the issue in it?
To be brief, it is runtime error when I call the display function for the Object C (in int main).
> A.inputmatrix();
if your code needs user input, then provide an example
> C = A.addmatrix(B);
that calls the assignment operator, which will do a shallow copy and then you'll delete the same pointer twice.
you need to provide a custom assignment operator as well.