I am making a matrix library and I would like to be able to do something like
Matrix<double> = Matrix<int> + Matrix<double>
is this possible?
Here is what I have now:
template<typename T>
Matrix<T>& Matrix<T>::operator+(const Matrix& rhs) {
if(w != rhs.w || h != rhs.h) {
printf("\e[31m[ERROR] Arithmetic Error: attempted to add %dx%d matrix to %dx%d matrix\e[0m\n", w, h, rhs.w, rhs.h);
}
else {
for(uint32_t i = 0;i < size;++i) {
m[i] += rhs.m[i];
}
}
return *this;
}
operator+which mutate its operands is strange, it looks more asoperator +=thanoperator+.