CArray::GetAt TYPE GetAt( int nIndex ) const;Return ValueThe array element currently at this index.ParametersTYPETemplate parameter specifying the type of the array elements.nIndexAn integer index that is greater than or equal to 0 and less than or equal to the value returned by GetUpperBound.ResReturns the array element at the specified index.Note Passing a negative value or a value greater than the value returned by GetUpperBound will result in a failed assertion. ............. ............. ............. CArray::ElementAt TYPE& ElementAt( int nIndex );Return ValueA reference to an array element.ParametersTYPETemplate parameter specifying the type of elements in the array.nIndexAn integer index that is greater than or equal to 0 and less than or equal to the value returned by GetUpperBound.ResReturns a temporary reference to the specified element within the array. It is used to implement the left-side assignment operator for arrays.
do u notice? the two functions have different kinds of return value ....check ur code ...
TYPE GetAt( int nIndex ) const;Return ValueThe array element currently at this index.ParametersTYPETemplate parameter specifying the type of the array elements.nIndexAn integer index that is greater than or equal to 0 and less than or equal to the value returned by GetUpperBound.ResReturns the array element at the specified index.Note Passing a negative value or a value greater than the value returned by GetUpperBound will result in a failed assertion.
.............
.............
.............
CArray::ElementAt
TYPE& ElementAt( int nIndex );Return ValueA reference to an array element.ParametersTYPETemplate parameter specifying the type of elements in the array.nIndexAn integer index that is greater than or equal to 0 and less than or equal to the value returned by GetUpperBound.ResReturns a temporary reference to the specified element within the array. It is used to implement the left-side assignment operator for arrays.
对呀俩函数返回类型就不一样呀,一个返回 index,一个返回引用
.......
ar.GetAt(0) = 0;//出错, ar.SetAt(0, 0);
ar.ElementAt(0) = 0; //OK,ElementAt取得的,可以作为左值(l value)
后者只返回其值 了!