al7elwah85
23-10-2005, 04:23 PM
Create a class DoubleSubscriptedArray. The class should be able to create an array containing any number of rows and any numbers of columns. The class should performs range checking to ensure that subscripts remain within the bounds of the array.
The class allows one array object to be assigned to another with the assignment operator. Objects of this array class know their size, so the size does not need to be passed separately as an argument when passing an array to a function. Entire arrays can be input or output with the stream-extraction and stream-insertion operators, respectively.
The class should provide operator() to perform double-subsripting operations. For example, in a 2-by-3 DoubleSupscriptedArray called a, the programmer could write a(1,3) to access the element at row 1 and column 3. The underlying representation of the double-subscripted array should be a single-subsripted array of integers with rows*columns number of elements.
Hint:
private:
int rows;
int columns;
int *ptr;
a(1,1)
a(1,2)
a(1,3)
a(2,1)
a(2,2)
a(2,3)
The class allows one array object to be assigned to another with the assignment operator. Objects of this array class know their size, so the size does not need to be passed separately as an argument when passing an array to a function. Entire arrays can be input or output with the stream-extraction and stream-insertion operators, respectively.
The class should provide operator() to perform double-subsripting operations. For example, in a 2-by-3 DoubleSupscriptedArray called a, the programmer could write a(1,3) to access the element at row 1 and column 3. The underlying representation of the double-subscripted array should be a single-subsripted array of integers with rows*columns number of elements.
Hint:
private:
int rows;
int columns;
int *ptr;
a(1,1)
a(1,2)
a(1,3)
a(2,1)
a(2,2)
a(2,3)