0
two dimensional matrix using class
https://code.sololearn.com/ca22a9a15a9A All of the output is showing zero and idk why.Also how can I print the inverse function of type Matrix in the output?
15 Answers
+ 2
You only did M2.inverse(). But kt should be M2 = M2.inverse() because you did not modify the Matrix but rather made a new object.
+ 1
You didn't give anything to M2. All the default value in the constructor parameters are used, which is 0.
+ 1
Copy M1 to M2? But you use M1 = M2.
+ 1
M2 = M2.inverse();
+ 1
Replace the main() with this and try again.
int main()
{
Matrix M1(2,3,4,5);
Matrix M2;
M2=M1;
M2.print();
M2.det();
M2.printdet();
M2=M2.inverse();
M2.print();
M2.isSingular();
M2.printSingular();
return 0;
}
+ 1
Martin Taylor & CarrieForle Thanks
0
@Martin yes it is taken from that book...@Carrie I am trying to copy M1 through M2 using the copy constructor
0
@Martin there was no array in the book so I didn't create one
0
@Carrie ok now that's a mistake..let me edit it
0
@Carrie it worked now..but what can I do about the inverse matrix..how can I show it?
0
yes I did it @carrie but the output not shown..how can I do it like can you please check the inverse function..it's type is of class matrix
0
ok I'll do it again
0
@Carrie I did it still the inverse result not shown in the output..cout<<temp in the inverse function causes an error since it's a matrix kind..so how can I show it now?
0
Did you print it with M2.print() after inverse()?
0
@Carrie I tried it at first in the print() but since it belongs to the type matrix it can't be done by using cout...and that's what I want to know like how to print an output value which is of class type
you see it's not double inverse() or int type ..it is Matrix inverse and the temp is also written as Matrix temp..now How can I cout temp?