Example: suppose we have a TMatrix
class, in which an instantiated object is encapsulated a two-dimensional array of int
elements. A possible solution for obtaining its specific element is the getEntrie(int row, int col)
function getEntrie(int row, int col)
returns an element by row and column number.
Another solution is to create a nested class, for example TPtrRow
, which stores a pointer to an int
. Then, we overload the [] operator for the TMatrix class so that it returns the TPtrRow object that holds the string, the number of which we passed when calling []. Similarly, we overload the operator [] for the class TPtrRow
- then using two operators in a row obj[row][col]
we get the element we need.
Actually, the question is: how can such a construction be implemented to those cases when we are dealing with N-dimensional arrays, N> 2?
TPtrRow
so that each successive call returns a matrix class with a dimension less than the initial one. - ߊߚߤߘTPtrRow
template? - isnullxbh[]
use the operator()
, which takes all the measurements at once. - ߊߚߤߘ