Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- template<class type>
- class matrix
- {
- private:
- type** matrix_data;
- public:
- matrix();
- matrix(type** matr){
- matrix_data = matr;
- }
- type* getElement(int m, int n){
- return matrix_data[m][n];
- }
- void setElement(int m, int n, type value){
- matrix_data[m][n] = value;
- }
- void setMatrix(type** Value_matrix){
- matrix_data = Value_matrix;
- }
- type** getMatrix(){
- return matrix_data;
- }
- type trace(){
- return matrix_data[0][0] + matrix_data[1][1] + matrix_data[2][2];
- }
- void print(){
- for (int i = 0;i < 3;++i){
- for(int j = 0; j < 3; ++j){
- cout << matrix_data[i][j];
- }
- }
- }
- ~matrix();
- };
- int main()
- {
- int mas[3][3] = {{1,2,2},{2,3,3},{4,5,6}};
- matrix <int> a;
- a.setMatrix(mas);
- cout << "Hello World!" << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement