This question has already been answered:
there is a class with an overloaded statement <<
template<class T> class Array { private: //... public: //... friend ostream& operator<<(ostream &os, const Array<T> &obj); }; The implementation of the overload is such (the implementation, as expected, in the header):
template<class T> ostream& operator<<(ostream &os, const Array<T> &obj) { //.. return os; } In Maine, I write the following code:
cout << "arr: " << arr << endl; As a result, it gives an error:
error: undefined reference to operator << (std :: ostream &, Array const &) '
What is the problem? I have already re-read everything in both Russian and English-speaking form, not one advice helps.