共用方式為


CArray::GetData

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

TYPE*** GetData( );**

Return Value

A pointer to an array element.

Parameters

TYPE

Template parameter specifying the type of the array elements.

Remarks

Use this member function to gain direct access to the elements in an 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.

Example

CArray<CPoint,CPoint> myArray;
int i;

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

// Add elements to the array.
CPoint* pPt = (CPoint*) myArray.GetData();
for (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();

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

CArray OverviewClass MembersHierarchy Chart

See Also   CArray::GetAt, CArray::SetAt, CArray::ElementAt