If N_ELEMENTS or SIZE is called with a scalar object that inherits from the IDL_Object class, these routines will call the overloaded function method MyOperator::_overloadSize, which returns a vector containing one element per “dimension” of the object. (You can define what constitutes a dimension for your object in any way you choose.) Each element of the vector reports the number of elements contained by the corresponding dimension.

The N_ELEMENTS function calls _overloadSize and multiplies the dimensions to calculate the total number of object elements. The SIZE function calls _overloadSize and uses the returned vector to report the object’s number of dimensions, the size of each dimension, and the total number of elements.

For example, you could create a subclass of IDL_Object that contains a pointer to a two-dimensional array. In this case, your _overloadSize method might return a two-element vector, with each element containing the size of the corresponding array dimension.

The default behavior for _overloadSize is to return the scalar value 1, which means the object is a scalar.

See Example: Overloading the SIZE and N_ELEMENTS Functions for a complete code example.