rendered paste body#include <iostream>using namespace std;template <class TValor>class Matrix { public: Matrix(); Matrix(int linhas, int colunas); Matrix(int linhas, int colunas, const TValor &valor); Matrix(const Matrix &matriz); //Metodos void Matrix :: redimensionar (int linhas, int colunas); TValor getlinhas() const { return this->i; } TValor getcolunas() const { return this->j; } private : int i,j; TValor *matriz; }; //Construtor Defaulttemplate <class TValor>Matrix<TValor> :: Matrix() { i=0; j=0; }//////////////////////////////////////Construtor de deois parametrostemplate <class TValor>Matrix<TValor> :: Matrix(int linhas, int colunas) { if ( linhas < 0 ) { this -> i = 0; cout << "Numero de linhas nao pode ser negativo"; }else{ if ( colunas < 0 ) { this -> j = 0; cout << "Numero de colunas nao pode ser negativo"; } } this->matriz = new TValor[i * j]; }//////////////////////////////////////Construtor por copia enviando parametrostemplate <class TValor>Matrix<TValor> :: Matrix(int linhas, int colunas, const TValor &m2) { if ( linhas < 0 ) { this -> i = 0; cout << "Numero de linhas nao pode ser negativo"; }else{ if ( colunas < 0 ) { this -> j = 0; cout << "Numero de colunas nao pode ser negativo"; } } for ( int contador = 0 ; contador <= (this->i*this->j); contador++) this->matriz[contador] = m2.matriz[contador]; }//////////////////////////////////////Construtor por copiatemplate <class TValor>Matrix<TValor> :: Matrix(const Matrix &m2) { this->matriz = new TValor[ i * j]; for ( int contador = 0 ; contador <= (this->i*this->j); contador++) this->matriz[contador] = m2.matriz[contador]; }//////////////////////////////////////MÉTODOS//1- Redimensiona a matriztemplate <class TValor>void Matrix<TValor> :: redimensionar(int linhas, int colunas) { if ( linhas < 0 ) { this -> i = 0; cout << "Numero de linhas nao pode ser negativo"; }else{ if ( colunas < 0 ) { this -> j = 0; cout << "Numero de colunas nao pode ser negativo"; } } this->matriz = new TValor[ i * j]; }////////////////////////////////////int main(){ int x; Matrix<int> m(3,3); cout<<"Matriz Criada"<<endl; cin >> x; m.redimensionar(-2,2); cout<<"Matriz redimensionada"; cin >> x; }