//matrix.cpp #include using namespace std; #include "matrix.h" Matrix::Matrix(int nrows, int ncols) { if (_values = (ValType *) new ValType[nrows * ncols]) { _nrows = nrows; _ncols = ncols; } } Matrix::~Matrix() { delete [] _values; } void Matrix::SetValue(int i, int j, ValType value) { _values[j + i * _ncols] = value; } ValType Matrix::GetValue(int i, int j) { return _values[j + i * _ncols]; } void Matrix::Print() { for (int i = 0; i < _nrows; i++) { for (int j = 0; j < _ncols; j++) cout << GetValue(i, j) << '\t'; cout << endl; } }