I have a class matrix, which is a wrapper over a double** array array. In it operator(i, j) overloaded, returning array[i][j] . When creating other matrices ( B , C ) in the methods of this class, you should contact directly B.array[i][j], C.array[i][j] or B(i, j), C(i, j) ?
2 answers
In class methods it is possible, as you understand, and this and that.
I would put it this way - if you do not plan to change the internal representation and do not need additional actions when referring to elements, then you can directly like .array[i][j] .
But, perhaps, it is better through operator() - because there is little that can change - for example, for debugging, you will need to write down the call log. A simple compiler operator will simply embed, so there should be no failure in efficiency.
Often, public functions provide additional checking before accessing real data, for example, checking whether indexes fall within the allowed range and throwing an exception if the condition is not met. In such cases, the use of these functions to implement other operations on the class may lead to unnecessary checks that are not actually needed, since You write the internal (library) code and know that it cannot go beyond the borders. Those. using operator(i, j) will be unnecessary, it suffices to explicitly refer to array[i][j] .
B,Cother classes (derivatives?) Or just names of variables of the class "matrix"? - 伪位蔚蠂慰位蠀蟿