Advertisement
HellFinger

Untitled

May 27th, 2020
373
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<class type>
  5. class matrix
  6. {
  7. private:
  8. type** matrix_data;
  9.  
  10.  
  11. public:
  12. matrix();
  13. matrix(type** matr){
  14. matrix_data = matr;
  15. }
  16.  
  17. type* getElement(int m, int n){
  18. return matrix_data[m][n];
  19. }
  20.  
  21. void setElement(int m, int n, type value){
  22. matrix_data[m][n] = value;
  23. }
  24.  
  25.  
  26. void setMatrix(type** Value_matrix){
  27. matrix_data = Value_matrix;
  28. }
  29.  
  30. type** getMatrix(){
  31. return matrix_data;
  32. }
  33.  
  34. type trace(){
  35. return matrix_data[0][0] + matrix_data[1][1] + matrix_data[2][2];
  36. }
  37.  
  38. void print(){
  39. for (int i = 0;i < 3;++i){
  40. for(int j = 0; j < 3; ++j){
  41. cout << matrix_data[i][j];
  42. }
  43. }
  44. }
  45.  
  46.  
  47. ~matrix();
  48.  
  49.  
  50.  
  51. };
  52.  
  53.  
  54. int main()
  55. {
  56.  
  57. int mas[3][3] = {{1,2,2},{2,3,3},{4,5,6}};
  58.  
  59. matrix <int> a;
  60.  
  61. a.setMatrix(mas);
  62.  
  63. cout << "Hello World!" << endl;
  64. return 0;
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement