I am implementing assignment operator function for a template matrix class. It should take care of different datatype matrix assignments. eg Integer matrix is assigned to a double matrix. for that i have following declaration:
template<class U> MyMatrix<T>& operator= (const MyMatrix<U> &rhs) {...}
My problem is, if i implement the fuction within class declaration, it works. But if i implement it outside the class declaration like,
template<class T, class U> MyMatrix<T>& MyMatrix<T>::operator= (const MyMatrix<U> &rhs){...}
i get following error:
error: no declaration matches ‘MyMatrix<T>& MyMatrix<T>::operator=(const MyMatrix<U>&)’
What am i doing wrong?
template<class T> template<class U> MyMatrix<T>& //etc.- you have a template within a template, not a template that takes 2 template parameters