17 Oct
2006
17 Oct
'06
2:07 p.m.
"YYW"
Arkadiy Vertleyb advised me to insert "const" in "line A". So, the new version of "line A" is: void operator << (ostream& os, const CMatrix<T>& m)
OK, there's no error. But, why?
Because:
static CMatrix<T> eye(int size) { return identity_matrix<T>(size); }
Returns an r-value, and...
template <class T_> friend ostream& operator << (ostream& os, CMatrix
& m); };
you are trying to bind this r-value to a non-const reference. Compiler correctly refuses to do this. IOW, compiler tries to prevent you from changing the temporary object since such changes wouldn't make any sence. HTH, Arkadiy