Share via


CAutoVectorPtr Class

This class represents a smart pointer object using vector new and delete operators.

Important

This class and its members cannot be used in applications that execute in the Windows Runtime.

template< 
typename T 
> class CAutoVectorPtr

Parameters

  • T
    The pointer type.

Members

Public Constructors

Name

Description

CAutoVectorPtr::CAutoVectorPtr

The constructor.

CAutoVectorPtr::~CAutoVectorPtr

The destructor.

Public Methods

Name

Description

CAutoVectorPtr::Allocate

Call this method to allocate the memory required by the array of objects pointed to by CAutoVectorPtr.

CAutoVectorPtr::Attach

Call this method to take ownership of an existing pointer.

CAutoVectorPtr::Detach

Call this method to release ownership of a pointer.

CAutoVectorPtr::Free

Call this method to delete an object pointed to by a CAutoVectorPtr.

Public Operators

Name

Description

CAutoVectorPtr::operator T *

The cast operator.

CAutoVectorPtr::operator =

The assignment operator.

Public Data Members

Name

Description

CAutoVectorPtr::m_p

The pointer data member variable.

Remarks

This class provides methods for creating and managing a smart pointer, which will help protect against memory leaks by automatically freeing resources when it falls out of scope. CAutoVectorPtr is similar to CAutoPtr, the only difference being that CAutoVectorPtr uses vector new[] and vector delete[] to allocate and free memory instead of the C++ new and delete operators. See CAutoVectorPtrElementTraits if collection classes of CAutoVectorPtr are required.

See CAutoPtr for an example of using a smart pointer class.

Requirements

Header: atlbase.h

See Also

Reference

CAutoPtr Class

Other Resources

ATL Class Overview