#include <iostream>
#include <fstream>
using namespace std;
const size_t SIZE = 4 ;
template < typename T>
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< T> & ) ;
const Matrix& operator= ( const Matrix< T> & ) ;
const Matrix& operator* ( const Matrix< T> & ) ;
void operator* = ( const Matrix< T> & ) ;
T* operator[ ] ( int row) ;
} ;
template < typename T>
ostream & operator<< ( ostream & os, const Matrix< T> & 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< T> & rhs)
{
for ( int i( 0 ) ; i < SIZE; ++ i)
{
for ( int j( 0 ) ; j < SIZE; ++ j)
{
is >> rhs.arr [ i] [ j] ;
}
}
return is;
}
int main( )
{
Matrix < int > m;
ifstream( "input.txt" ) >> m;
return 0 ;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8ZnN0cmVhbT4KCnVzaW5nIG5hbWVzcGFjZSBzdGQ7Cgpjb25zdCBzaXplX3QgU0laRSA9NDsKCnRlbXBsYXRlPHR5cGVuYW1lIFQ+CmNsYXNzIE1hdHJpeAp7CnByaXZhdGU6CiAgICBUIGFycltTSVpFXVtTSVpFXTsKICAgIGZyaWVuZCAgb3N0cmVhbSYgb3BlcmF0b3IgPDwgKG9zdHJlYW0gJiwgY29uc3QgTWF0cml4ICYpOwogICAgZnJpZW5kICBpc3RyZWFtJiBvcGVyYXRvciA+PiAoaXN0cmVhbSAmLCBNYXRyaXggJik7CiAgICB2b2lkIGluaXRpYWxpemUoKTsvLyDRhNGD0L3QutGG0LjRjyDQutC+0YLQvtGA0LDRjyDQt9Cw0L/QvtC70L3Rj9C10YIg0LzQsNGC0YDQuNGG0YMg0LrQsNC6INC10LTQuNC90LjRh9C90YPRjgoKcHVibGljOgogICAgTWF0cml4KCkge30KICAgIE1hdHJpeChjb25zdCBNYXRyaXg8VD4mKTsKICAgIGNvbnN0IE1hdHJpeCYgb3BlcmF0b3I9KGNvbnN0IE1hdHJpeDxUPiYpOwogICAgY29uc3QgTWF0cml4JiBvcGVyYXRvciooY29uc3QgTWF0cml4PFQ+Jik7CiAgICB2b2lkICBvcGVyYXRvcio9KGNvbnN0IE1hdHJpeDxUPiAmKTsKICAgIFQqIG9wZXJhdG9yW10oaW50IHJvdyk7Cn07Cgp0ZW1wbGF0ZTwgdHlwZW5hbWUgVD4Kb3N0cmVhbSAmIG9wZXJhdG9yPDwob3N0cmVhbSAmIG9zLCBjb25zdCBNYXRyaXg8VD4gJiByaHMpCnsKICAgIGZvciAoaW50IGkoMCk7IGkgPCBTSVpFOyArK2kpCiAgICB7CiAgICAgICAgZm9yIChpbnQgaigwKTsgaiA8IFNJWkU7ICsraikKICAgICAgICB7CiAgICAgICAgICAgIG9zIDw8IHJocy5hcnJbaV1bal0gPDwgJyAnOwogICAgICAgIH0KICAgICAgICBvcyA8PCBlbmRsOwogICAgfQogICAgcmV0dXJuIG9zOwp9Cgp0ZW1wbGF0ZTwgdHlwZW5hbWUgVD4KaXN0cmVhbSAmIG9wZXJhdG9yPj4oaXN0cmVhbSYgIGlzLCBNYXRyaXg8VD4gJiByaHMpCnsKICAgIGZvciAoaW50IGkoMCk7IGkgPCBTSVpFOyArK2kpCiAgICB7CiAgICAgICAgZm9yIChpbnQgaigwKTsgaiA8IFNJWkU7ICsraikKICAgICAgICB7CiAgICAgICAgICAgIGlzID4+IHJocy5hcnJbaV1bal07CiAgICAgICAgfQogICAgfQogICAgcmV0dXJuIGlzOwp9CgppbnQgbWFpbigpCnsKCU1hdHJpeCA8aW50PiBtOwoJaWZzdHJlYW0oImlucHV0LnR4dCIpID4+IG07CgkKCXJldHVybiAwOwp9
compilation info
prog.cpp:13:60: warning: friend declaration 'std::ostream& operator<<(std::ostream&, const Matrix<T>&)' declares a non-template function [-Wnon-template-friend]
friend ostream& operator << (ostream &, const Matrix &);
^
prog.cpp:13:60: note: (if this is not what you intended, make sure the function template has already been declared and add <> after the function name here)
prog.cpp:14:54: warning: friend declaration 'std::istream& operator>>(std::istream&, Matrix<T>&)' declares a non-template function [-Wnon-template-friend]
friend istream& operator >> (istream &, Matrix &);
^
/home/qLEnJR/ccfFikXL.o: In function `main':
prog.cpp:(.text.startup+0x34): undefined reference to `operator>>(std::istream&, Matrix<int>&)'
collect2: error: ld returned 1 exit status
stdout