Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. class matrix{
  5. struct Array;
  6. Array *pArray;
  7. public:
  8. class Dref;
  9. matrix();
  10. matrix( unsigned int k);
  11. matrix( unsigned int w,unsigned int k);
  12.  
  13. /*construktor kopiujacy */
  14. matrix(const matrix &);
  15.  
  16. ~matrix();
  17. matrix& operator=(const double*);
  18. matrix& operator=(const matrix&);
  19.  
  20. matrix operator+ (const matrix &) const;
  21. matrix operator-(const matrix &) const;
  22. matrix operator*(const matrix &) const;
  23.  
  24. matrix & operator +=(const matrix &);
  25. matrix & operator -=(const matrix &);
  26. matrix & operator *=(const matrix &);
  27.  
  28.  
  29.  
  30. friend ostream& operator<<(ostream&, const matrix&);
  31. friend istream& operator>>(istream&, const matrix&);
  32.  
  33. bool operator==(const matrix&) const;
  34.  
  35.  
  36. double operator()(unsigned int i,unsigned int j) const;
  37. Dref operator()(unsigned int i, unsigned int j);
  38.  
  39.  
  40. double read(unsigned int i, unsigned int j);
  41.  
  42. void write(double **);
  43.  
  44.  
  45. };
  46.  
  47.  
  48. class matrix:: Dref{
  49. friend class matrix;
  50. matrix & m;
  51. int i,j;
  52.  
  53. Dref(matrix &mtr, unsigned int ii, unsigned int jj): m(mtr), i(ii), j(jj)
  54. {
  55.  
  56. };
  57.  
  58. public:
  59. operator double() const
  60. {
  61. cout << "operator double() const"<<endl;
  62. return m.pArray->read(i,j);
  63. }
  64. };
  65. inline double matrix::read(unsigned int i,unsigned int j)
  66. {
  67.  
  68. return &matrix[i][j];
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement