I am having a hard time figuring out why my Overloaded operation does not return what I am looking for. If I display my matrix right after the calculations, it works just fine. I cannot figure out why I can't return the class and display the matrix. Is my destructor deleting the pointer in my class when it gets returned? (I do not think that would cause a shallow copy?) I just cannot see what I am missing. Thank you in advance guys.
int rows, columns;
cout << "Enter numbers of rows\n";
cin >> rows;
cout << "Enter number of columns\n";
cin >> columns;
cout << "Enter the elements for the first matrix\n";
cout << "Enter the elements of the second matrix\n";
m3 = m1 * m2;
You don't provide a copy constructor or assignment operator. So when you perform these operations, you get the default, which is copies of all your members.
Some of your members are pointers, so you get two instances pointing to the same stuff. When one goes, it deletes them, leaving the other pointing to delete memory, dangling references. If the heap reuses those addresses, it'll corrupt the state of that remaining instance.