Why the following code doesn't compile?
template<typename T>
std::ostream &operator<<(std::ostream &os, const Matrix<T> &matrix)
{
Matrix<T>::iterator it_begin=matrix.begin();
}
I get the following:
error: expected ';' after expression Matrix::iterator it_begin=matrix.begin();
use of undeclared identifier 'it_begin' Matrix::iterator it_begin=matrix.begin();
In my Generic class Matrix<T>
I wrote under public the following:
class iterator;
iterator begin();
and begin implementation is:
template<class T>
typename Matrix<T>::iterator Matrix<T>::begin() {
return iterator(this, 0);
}
Edit
using the suggested solution I'm getting linker error:
Undefined symbols for architecture x86_64:
"mtm::operator<<(std::__1::basic_ostream<char,
std::__1::char_traits<char> >&, mtm::Matrix<int> const&)", referenced
from:
_main in main.cpp.o ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to
see invocation)