CArray

template<classTYPE**,classARG_TYPE>classCArray:publicCObject**

Parameters

TYPE

Template parameter specifying the type of objects stored in the array. TYPE is a parameter that is returned by CArray.

ARG_TYPE

Template parameter specifying the argument type used to access objects stored in the array. Often a reference to TYPE. ARG_TYPE is a parameter that is passed to CArray.

Remarks

The CArray class supports arrays that are are similar to C arrays, but can dynamically shrink and grow as necessary.

Array indexes always start at position 0. You can decide whether to fix the upper bound or allow the array to expand when you add elements past the current bound. Memory is allocated contiguously to the upper bound, even if some elements are null.

As with a C array, the access time for a CArray indexed element is constant and is independent of the array size.

Tip   Before using an array, use SetSize to establish its size and allocate memory for it. If you do not use SetSize, adding elements to your array causes it to be frequently reallocated and copied. Frequent reallocation and copying are inefficient and can fragment memory.

If you need a dump of individual elements in an array, you must set the depth of the CDumpContext object to 1 or greater.

Certain member functions of this class call global helper functions that must be customized for most uses of the CArray class. See the topic Collection Class Helpers in the Macros and Globals section.

When elements are removed from a CArray object, the helper function DestructElements is called. When elements are added, the helper function ConstructElements is called.

Array class derivation is similar to list derivation.

For more information on using CArray, see the article in Visual C++ Programmer's Guide.

#include <afxtempl.h>

Class MembersBase ClassHierarchy Chart

Sample   

See Also   CObArray, DestructElements, ConstructElements, Collection Class Helpers