CTypedPtrArray Class

Provides a type-safe "wrapper" for objects of class CPtrArray or CObArray.

template< class BASE_CLASS, class TYPE >
class CTypedPtrArray : public BASE_CLASS

Parameters

  • BASE_CLASS
    Base class of the typed pointer array class; must be an array class (CObArray or CPtrArray).

  • TYPE
    Type of the elements stored in the base-class array.

Members

Public Methods

Name

Description

CTypedPtrArray::Add

Adds a new element to the end of an array. Grows the array if necessary

CTypedPtrArray::Append

Adds the contents of one array to the end of another. Grows the array if necessary

CTypedPtrArray::Copy

Copies another array to the array; grows the array if necessary.

CTypedPtrArray::ElementAt

Returns a temporary reference to the element pointer within the array.

CTypedPtrArray::GetAt

Returns the value at a given index.

CTypedPtrArray::InsertAt

Inserts an element (or all the elements in another array) at a specified index.

CTypedPtrArray::SetAt

Sets the value for a given index; array not allowed to grow.

CTypedPtrArray::SetAtGrow

Sets the value for a given index; grows the array if necessary.

Public Operators

Name

Description

CTypedPtrArray::operator [ ]

Sets or gets the element at the specified index.

Remarks

When you use CTypedPtrArray rather than CPtrArray or CObArray, the C++ type-checking facility helps eliminate errors caused by mismatched pointer types.

In addition, the CTypedPtrArray wrapper performs much of the casting that would be required if you used CObArray or CPtrArray.

Because all CTypedPtrArray functions are inline, use of this template does not significantly affect the size or speed of your code.

For more information on using CTypedPtrArray, see the articles Collections and Template-Based Classes.

Inheritance Hierarchy

BASE_CLASS

CTypedPtrArray

Requirements

Header: afxtempl.h

See Also

Reference

Hierarchy Chart

CPtrArray Class

CObArray Class

Concepts

MFC Sample COLLECT