Important Update: Removing the delegation of friend solved the problem Partially but why? and how may I keep it as friend...
Why the following code gets me linker error?
Dimensions dims2(3 ,14);//Fixed class 100% the bug isn't cause by it
Matrix<int> mat_2(dims2, 5);
std::cout << mat_2;
My class:
template<class T>
class Matrix {
public:
friend std::ostream &operator<<(std::ostream &os, const Matrix<T> &matrix);
;}
in .h
file I have:
template<typename T>
std::ostream &operator<<(std::ostream &os, const Matrix<T> &matrix) {}
I get the following:
Undefined symbols for architecture x86_64:
"mtm::operator<<(std::__1::basic_ostream >&, mtm::Matrix const&)", referenced from: _main in main.cpp.o ld: symbol(s) not found for architecture x86_64clang: error: linker command failed with exit code 1 (use -v to see invocation)