#include using namespace std; template 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 Default template Matrix :: Matrix() { i=0; j=0; } //////////////////////////////////// //Construtor de deois parametros template Matrix :: 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 parametros template Matrix :: 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 copia template Matrix :: 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 matriz template void Matrix :: 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 m(3,3); cout<<"Matriz Criada"<> x; m.redimensionar(-2,2); cout<<"Matriz redimensionada"; cin >> x; }