CHStringArray::operator [ ]

[The CHStringArray class is part of the WMI Provider Framework which is now considered in final state, and no further development, enhancements, or updates will be available for non-security related issues affecting these libraries. The MI APIs should be used for all new development.]

These subscript operators set or get the element at the specified index. These operators are a convenient substitute for the SetAt and GetAt methods.

CHString& operator []( 
  int nIndex
);

CHString operator []( 
  int nIndex
) const;

Parameters

nIndex

An integer index that is greater than or equal to zero and less than or equal to the value returned by GetUpperBound

Return Values

The subscript operators return the CHString pointer element currently at this index.

Remarks

You can use the first operator, which calls for arrays that are not const, on either the right (r-value) or the left (l-value) side of an assignment statement. The second, which calls for const arrays, can be used only on the right.

The debug version of the library asserts if the subscript (either on the left or right side of an assignment statement) is out of bounds.

Examples

The following code example shows the use of CHStringArray::operator [].

CHStringArray array;
CHString s;

array.Add( L"String 1" ); // Element 0 
array.Add( L"String 2" ); // Element 1 
s = array[0]; // Get element 0
assert( s == L"String 1" ); 

array[0] = L"String 3"; // Replace element 0 
assert( array[0] == L"String 3" );

Requirements

Requirement Value
Minimum supported client
Windows Vista
Minimum supported server
Windows Server 2008
Header
ChStrArr.h (include FwCommon.h)
Library
FrameDyn.lib
DLL
FrameDynOS.dll;
FrameDyn.dll

See also

CHStringArray::Add

CHStringArray::GetAt

CHStringArray::SetAt