const CObject** GetData( ) const;
CObject** GetData( );
Return Value
A pointer to the array of CObject pointers.
Remarks
Use this member function to gain direct access to the elements in the array. If no elements are available, GetData returns a null value.
While direct access to the elements of an array can help you work more quickly, use caution when calling GetData; any errors you make directly affect the elements of your array.
The following table shows other member functions that are similar to CObArray::GetData.
Class | Member Function |
CByteArray | const BYTE* GetData( ) const; BYTE* GetData( ); |
CDWordArray | const DWORD* GetData( ) const; DWORD* GetData( ); |
CPtrArray | const void** GetData( ) const; void** GetData( ); |
CStringArray | const CString* GetData( ) const; CString* GetData( ); |
CUIntArray | const UINT* GetData( ) const; UINT* GetData( ); |
CWordArray | const WORD* GetData( ) const; WORD* GetData( ); |
Example
See CObList::CObList for a listing of the CAge
class used in all collection examples.
CObArray myArray;
int i;
// Allocate memory for at least 32 elements.
myArray.SetSize(32, 128);
// Add elements to the array.
CAge** ppAge = (CAge**) myArray.GetData();
for (i=0;i < 32;i++,ppAge++)
*ppAge = new CAge( i );
// Only keep first 5 elements and free extra (unused) bytes.
myArray.SetSize(5, 128);
myArray.FreeExtra();
#ifdef _DEBUG
afxDump.SetDepth( 1 );
afxDump << "myArray: " << &myArray << "\n";
#endif
CObArray Overview | Class Members | Hierarchy Chart
See Also CObArray::GetAt, CObArray::SetAt, CObArray::ElementAt