In the program I used the assert statement to compare the matrices and operators are implemented using function overloading.
Below is the part of code of assert-
Mat2x2 m1(2.5, 3.6, 8.7, 5.8);
Mat2x2 t1 = m1;
++m1; // ++Mat2x2
assert(m1 == t1 + 1);
--m1; // --Mat2x2
assert(m1 == t1);
Below is the code of operator overloading of "==" operator-
bool operator==(const Mat2x2& m1, const Mat2x2& m2)
{
return ((m1[0] == m2[0]) && (m1[1] == m2[1]) && (m1[2] == m2[2]) && (m1[3] == m2[3]));
}
Below is the code of operator overloading of "++" and "--" operator-
Mat2x2& Mat2x2::operator++() {
*this += 1;
return *this;
}
Mat2x2& Mat2x2::operator--() {
*this -= 1;
return *this;
}
While i am printing the value of m1 and t1, it seems to be same and also have the same data type. The result is below-
m1: [2.50 , 3.60 , 8.70 , 5.80]
t1: [2.50 , 3.60 , 8.70 , 5.80]
Assertion failed: m1 == t1
Values seems to be same, still the assertion is failed.
How can i remove this error