Define a SparseMatrix class for compressed representation of 2D matrices in which a large number of elements are zero, using number of rows, columns non zero elements, and an array of elements with location and value. Allow file I/O and a constructor from the Matrix class (fig 8.9)
What will be an ideal response?
```
class SparseEle{
public:
SparseEle(){}
SparseEle(int, int, int); // Constructor with row, col, value
private:
int row, column, value;
friend istream& operator>>(istream&, SparseEle&);
friend ostream& operator<<(ostream&, const SparseEle&);
};
class SparseMatrix{
public:
SparseMatrix(){numNonZero = 0;}
SparseMatrix(const Matrix&); // Converts from Matrix class
~SparseMatrix();
private:
int rows, columns, numNonZero;
SparseEle* nonZeroList;
friend istream& operator>>(istream&, SparseMatrix&);
friend ostream& operator<<(ostream&, const SparseMatrix&);
};
int main()
{
string infilename1, infilename2,
outfilename;
SparseMatrix sm1;
Matrix m1;
```
You might also like to view...
What task is accomplished by the following code?
```Dim intFirstArray(2) As Integer Dim intSecondArray(2) As Integer intFirstArray(0) = 10 intFirstArray(1) = 19 intFirstArray(2) = 26 intSecondArray = intFirstArray ``` a. Two distinct arrays are created in memory with the same values. b. intFirstArray and intSecondArray reference the same array in memory c. This code will generate a run-time error. You cannot assign the name of one array to another. d. intFirstArray is initialized with values but intSecondArray contains no values
Several people who connect to the Internet and communicate in real time by typing comments to each other is called a(n) ____.
A. chat group B. instant message C. VoIP D. social network
Status indicators are located on the Select one:
a. Horizontal scroll bar b. Formatting toolbar c. Vertical scroll bar d. Formula bar
Explain the advantage of creating a form with a subform.
What will be an ideal response?