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...

Method shuffle is a member of __________.

a. class Arrays. b. class Collections. c. interface Collection. d. Interface List.

Computer Science & Information Technology

What is the usefulness of conventions for Web users?

What will be an ideal response?What will be an ideal response?

Computer Science & Information Technology

Predefined page layouts called ____ can be applied to existing pages or used as a basis for designing new pages.

A. maps B. indexes C. templates D. rosters

Computer Science & Information Technology

Describe the process of creating an AutoKeys macro

What will be an ideal response?

Computer Science & Information Technology