Share via


CObArray::GetData

Utilice esta función miembro para obtener acceso directo a los elementos de la matriz.

const CObject** GetData( ) const;  
CObject** GetData( );

Valor devuelto

Un puntero a la matriz de punteros de CObject .

Comentarios

Si no hay elementos disponibles, GetData devuelve un valor null.

Mientras el acceso directo a los elementos de una matriz puede ayudarle a trabajar más rápidamente, tenga cuidado al llamar a GetData; cualquier error hace directamente a los elementos de la matriz.

La tabla siguiente se muestran otras funciones miembro que son similares a CObArray::GetData.

Clase

Función miembro

CByteArray

const const BYTE* GetData (); BYTE* GetData ();

CDWordArray

const const DWORD* GetData (); DWORD* GetData ();

CPtrArray

const void ** const GetData (); void ** GetData ();

CStringArray

const de CString* GetData const (); CString* GetData ();

CUIntArray

const const UINT* GetData (); UINT* GetData ();

CWordArray

const const WORD* GetData (); WORD* GetData ();

Ejemplo

Vea CObList:: CObList para una lista de la clase de CAge utilizada en todos los ejemplos de la colección.

CObArray myArray;

// Allocate memory for at least 32 elements.
myArray.SetSize(32, 128);

// Add elements to the array.
CAge** ppAge = (CAge**) myArray.GetData();
for (int i = 0; i < 32; i++, ppAge++)
   *ppAge = new CAge(i);

// Only keep first 5 elements and free extra (unused) bytes.
for (int i = 5; i < myArray.GetCount(); i++)
{
   delete myArray[i]; // free objects before resetting array size.         
}
myArray.SetSize(5, 128);
myArray.FreeExtra(); // only frees pointers.

#ifdef _DEBUG
    afxDump.SetDepth(1);
    afxDump << _T("myArray: ") << &myArray << _T("\n");
#endif      

Requisitos

encabezado: afxcoll.h

Vea también

Referencia

Clase de CObArray

Gráfico de jerarquía

CObArray::GetAt

CObArray::SetAt

CObArray::ElementAt