XLL+ Class Library (7.0)

CXlOper::operator []

Returns an item from an array

CXlCell operator [](
   size_t szItem = 0
);
CXlConstCell operator [](
   size_t szItem
) const;

Parameters

szItem

The row or column of the required value within the array. The first item is at szItem = 0.

Return Value

This operator returns an object which contains a reference to a cell contained within a single-dimensional array.

The operator is equivalent to a call to VectorCell().

Remarks

If the CXlOper does not contain a one-dimensional array, or if szItem is out of range, then the function will throw an exception of type CXlOutOfRangeException.

Breaking change

Under previous versions of XLL+ (5 and below), this operator returned a reference to a CXlOper type, which was contained within the outer CXlOper. In order to support both Excel 2007 and older versions of Excel, this functionality has had to be changed.

The operator now returns a new class of object, CXlCell or CXlConstCell, which can be used to refer to the cell, but is not itself of type CXlOper.

If your code retained a copy of the return value, as in for instance:

const CXlOper& item = xloArray[i];
total += item.ToDouble();

then it must be changed. The code above becomes:

CXlConstCell item = xloArray[i];
total += item.ToDouble();

If your code simply used the returned value without retaining a copy of it, then it will continue to compile. For example, the following code does not need to change:

xloArray[i] = 0.0;

Example

CXlOper::operator [] Example

Requirements

Header: xllplus.h

See Also

CXlOper Class | CXlOper Methods | CXlCell | CXlConstCell | CXlOper::VectorCell