Export (0) Print
Expand All


Use this member function to gain direct access to the elements in an array.

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


Template parameter specifying the type of the array elements.

A pointer to an array element.

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.

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);

#if _DEBUG
   afxDump << "myArray: " << &myArray << "\n";

Header: afxtempl.h

© 2014 Microsoft