次の方法で共有


Interpretation of Subscript Operator

 

The latest version of this topic can be found at Interpretation of Subscript Operator.

Like other operators, the subscript operator ([ ]) can be redefined by the user. The default behavior of the subscript operator, if not overloaded, is to combine the array name and the subscript using the following method:

*((array-name) + (subscript))

As in all addition that involves pointer types, scaling is performed automatically to adjust for the size of the type. Therefore, the resultant value is not subscript bytes from the origin of array-name; rather, it is the subscriptth element of the array. (For more information about this conversion, see Additive Operators.)

Similarly, for multidimensional arrays, the address is derived using the following method:

((
array-name ) + ( subscript 1  max2 * max3*...maxn) + subscript2 * max3...max*n) . . . + subscriptn))

See Also

Arrays