const size_t SIZE = 4; template class Matrix { private: T arr[SIZE][SIZE]; friend ostream& operator << (ostream &, const Matrix &); friend istream& operator >> (istream &, Matrix &); void initialize();// функция которая заполняет матрицу как единичную public: Matrix(); Matrix(const Matrix&); const Matrix& operator=(const Matrix&); const Matrix& operator*(const Matrix&); void operator*=(const Matrix &); T* operator[](int row); }; template< typename T> ostream & operator<<(ostream & os, const Matrix & rhs) { for (int i(0); i < SIZE; ++i) { for (int j(0); j < SIZE; ++j) { os << rhs.arr[i][j] << ' '; } os << endl; } return os; } template< typename T> istream & operator>>(istream& is, Matrix & rhs) { for (int i(0); i < SIZE; ++i) { for (int j(0); j < SIZE; ++j) { is >> rhs.arr[i][j]; } } return is; } friend ostream& operator << (ostream &, const Matrix &); friend istream& operator >> (istream &, Matrix &); prog.cpp:13:64: warning: friend declaration 'std::ostream& operator<<(std::ostream&, const Matrix&)' declares a non-template function [-Wnon-template-friend] friend ostream& operator << (ostream &, const Matrix &); ^ prog.cpp:13:64: note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here) template friend ostream& operator << (ostream &, const Matrix &); template friend istream& operator >> (istream &, Matrix &); friend ostream& operator << (ostream &, const Matrix &); friend istream& operator >> (istream &, Matrix &); friend ostream& operator << (ostream &, const Matrix &); friend istream& operator >> (istream &, Matrix &); template< typename T> std::ostream & operator<<(std::ostream & os, const Matrix & rhs) { ... } friend ostream& operator << (ostream &, const Matrix &); std::ostream & operator<<(std::ostream & os, const Matrix & rhs) { ... } template< typename T> std::ostream& operator<<(std::ostream & os, const Matrix & rhs) { ... } friend ostream& operator <<(ostream & os, const Matrix & rhs); friend istream& operator >>(istream &, Matrix &); template class Matrix; template< typename T> std::ostream& operator<<(std::ostream & os, const Matrix & rhs) { ... } template< typename T> std::istream & operator>>(std::istream& is, Matrix & rhs) { ... } template class Matrix { private: T arr[SIZE][SIZE]; friend ostream& operator <<(ostream &, const Matrix &); friend istream& operator >>(istream &, Matrix &); ... }; friend ostream& ::operator << (ostream &, const Matrix &); friend istream& ::operator >> (istream &, Matrix &); template class Matrix; template ostream & operator<< (ostream &, const Matrix &); template istream& operator >> (istream &, Matrix &); template class Matrix { private: T arr[SIZE][SIZE]; // объявляем friend'ом конкретную специализацию friend ostream& operator << <> (ostream &, const Matrix &); // обратите внимание на <> friend istream& operator >> <> (istream &, Matrix &); ...