Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const size_t SIZE = 4;
- template<typename T>
- class Matrix
- {
- private:
- T arr[SIZE][SIZE];
- friend ostream& operator << (ostream &, const Matrix<T> &);
- friend istream& operator >> (istream &, Matrix<T> &);
- 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;
- }
- friend ostream& operator << (ostream &, const Matrix<T> &);
- friend istream& operator >> (istream &, Matrix<T> &);
- prog.cpp:13:64: 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<T> &);
- ^
- 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 <typename T1> friend ostream& operator << (ostream &, const Matrix<T1> &);
- template <typename T1> friend istream& operator >> (istream &, Matrix<T1> &);
- friend ostream& operator << (ostream &, const Matrix<T> &);
- friend istream& operator >> (istream &, Matrix<T> &);
- friend ostream& operator << (ostream &, const Matrix<int> &);
- friend istream& operator >> (istream &, Matrix<int> &);
- template< typename T>
- std::ostream & operator<<(std::ostream & os, const Matrix<T> & rhs)
- {
- ...
- }
- friend ostream& operator << (ostream &, const Matrix<int> &);
- std::ostream & operator<<(std::ostream & os, const Matrix<int> & rhs)
- {
- ...
- }
- template< typename T>
- std::ostream& operator<<(std::ostream & os, const Matrix<T> & rhs)
- {
- ...
- }
- friend ostream& operator <<<T>(ostream & os, const Matrix & rhs);
- friend istream& operator >><T>(istream &, Matrix &);
- template<typename T>
- class Matrix;
- template< typename T>
- std::ostream& operator<<(std::ostream & os, const Matrix<T> & rhs)
- {
- ...
- }
- template< typename T>
- std::istream & operator>>(std::istream& is, Matrix<T> & rhs)
- {
- ...
- }
- template<typename T>
- class Matrix
- {
- private:
- T arr[SIZE][SIZE];
- friend ostream& operator <<<T>(ostream &, const Matrix &);
- friend istream& operator >><T>(istream &, Matrix &);
- ...
- };
- friend ostream& ::operator << (ostream &, const Matrix<T> &);
- friend istream& ::operator >> (istream &, Matrix<T> &);
- template<typename T>
- class Matrix;
- template<typename T>
- ostream & operator<< (ostream &, const Matrix<T> &);
- template<typename T>
- istream& operator >> (istream &, Matrix<T> &);
- template<typename T>
- class Matrix
- {
- private:
- T arr[SIZE][SIZE];
- // объявляем friend'ом конкретную специализацию
- friend ostream& operator << <> (ostream &, const Matrix &); // обратите внимание на <>
- friend istream& operator >> <> (istream &, Matrix &);
- ...
Add Comment
Please, Sign In to add comment