CString::operator []

Syntax

char operator []( int nIndex ) const;

Remarks

You can think of a CString object as an array of characters. The subscript ([]) operator returns a single character specified by the zero-base index in nIndex. This operator is a convenient substitute for the GetAt member function.

You can use the subscript ([]) operator on the right side of an expression (r-value semantics), but you cannot use it on the left side of an expression (l-value semantics). That is, you can use this operator to get characters in a CString, but you cannot use it to set characters in the CString.

Example

CString s( "abc" );

ASSERT( s[1] == 'b' );

See Also

CString::GetAt, CString::SetAt