Write a constructor that initializes the matrix dimensions and sets all elements to initVal.
const int MAX_ROWS = 10;
const int MAX_COLS = 10;
class Matrix {
public:
Matrix() {}
private:
int rows;
int cols;
int mat[MAX_ROWS][MAX_COLS];
};
Necessary modifications to class definition are underlined
lass Matrix {
public:
Matrix() {}
Matrix( int, int, int );
private:
int rows;
int cols;
int mat[MAX_ROWS][MAX_COLS];
friend void multElements( Matrix&, const Matrix&, const Matrix&);
};
// #3
Matrix::Matrix( int r, int c, int initVal )
{
rows = r;
cols = c;
for (int i = 0; i < r; ++i)
for (int j = 0; j < c; ++j)
mat[i][j] = initVal;
}
Computer Science & Information Technology
You might also like to view...
When inserting a column chart, a worksheet appears in which the ________ represent the columns
Fill in the blank(s) with correct word
Computer Science & Information Technology
FIGURE 7- 1Figure 7-1 above is a(n) ____.
A. flowchart B. truth table C. evaluation grid D. rule table
Computer Science & Information Technology