I created a matrix class and want to add two matrices of different data types. As for int and double return, the type of the matrix must be double. How can I do it??? This is my code.
template<class X> class Matrix { .......... ........ template<class U> Matrix<something> operator+(Matrix<U> &B) { if((typeid(a).before(typeid(Ba)))) Matrix<typeof(Ba)> res(1,1); else Matrix<typeof(a)> res(1,1); }
What should be "something" here?
And what needs to be done so that I can use "res" outside if else statement ???
source share