Microsoft Foundation Classes (mfc.hlp) (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
CObArray::SetAt
CObArray                                    Up Contents Index Back
──Microsoft Foundation Classes──────────────────────────────────────────────
 
  void SetAt( int nIndex, CObject* newElement );
 
  Parameter    Description
 
  <nIndex>     An integer index that is greater than or equal to 0 and
               less than or equal to GetUpperBound().
 
  <newElement> The object pointer to be inserted in this array. A NULL
               value is allowed.
 
  Remarks
 
  Sets the array element at the specified index. SetAt will not cause the
  array to grow. Use SetAtGrow if you want the array to grow
  automatically.
 
  You must ensure that your index value represents a valid position in the
  array. If it is out of bounds, then the Debug version of the library
  asserts.
 
  Example
 
  CObArray array;
  CObject* pa;
 
  array.Add( new CAge( 21 ) ); // Element 0
  array.Add( new CAge( 40 ) ); // Element 1
  if( ( pa = array.GetAt( 0 ) ) != NULL )
  {
      array.SetAt( 0, new CAge( 30 ) );  // Replace element 0
      delete pa; // Delete the original element at 0
  }
 
  The results from this program are as follows:
 
  SetAt example: A CObArray with 2 elements
      [0] = a CAge at $47E0 30
      [1] = a CAge at $47A0 40
 
  See Also
 
  CObArray::GetAt, CObArray::SetAtGrow, CObArray::ElementAt,
  CObArray::operator []
 
 
                                     -♦-