Compartir a través de


CArray::GetData

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

const TYPE* GetData( ) const; 
TYPE* GetData( );

Parámetros

  • TYPE
    Parámetro de plantilla que especifica el tipo de los elementos de la matriz.

Valor devuelto

Un puntero a un elemento de matriz.

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.

Ejemplo

CArray<CPoint,CPoint> myArray;

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

// Add elements to the array.
CPoint* pPt = (CPoint*) myArray.GetData();
for (int i = 0; i < 32; i++, pPt++)
   *pPt = CPoint(i, 2*i);

// Only keep first 5 elements and free extra (unused) bytes.
myArray.SetSize(5, 128);
myArray.FreeExtra();

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

Requisitos

encabezado: afxtempl.h

Vea también

Referencia

CArray Class

Gráfico de jerarquías

CArray::GetAt

CArray::SetAt

CArray::ElementAt