Как мне сделать так, чтобы размер матрицы и значение её элементов я вводил сам (то есть динамически)?
#pragma once
#include <iostream>
#include <string>
#include <ctime>
using namespace std;
class Matrix {
int **matr;
int rows;
int cols;
public:
int *operator[](int k) {
return matr[k];
}
Matrix operator+(Matrix obj) {
Matrix tmp(0);
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
tmp[i][j] = matr[i][j] + obj[i][j];
return tmp;
}
Matrix operator*(Matrix obj) {
Matrix tmp(0);
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
for (int k = 0; k < n; k++)
tmp[i][j] += matr[i][k] * obj[k][j];
return tmp;
}
void show() {
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
printf("%3d", matr[i][j]);
}
cout << endl;
}
}
};