Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

CHeapPtr::Allocate

 

Call this method to allocate memory on the heap to store objects.


      bool Allocate(
   size_t nElements = 1 
) throw( );

nElements

The number of elements used to calculate the amount of memory to allocate. The default value is 1.

Returns true if the memory was successfully allocated, false on failure.

The allocator routines are used to reserve enough memory on the heap to store nElement objects of a type defined in the constructor.

Example

// Create a new CHeapPtr object
CHeapPtr <int> myHP;
// Allocate space for 10 integers on the heap
myHP.Allocate(10);

Requirements

Header: atlalloc.h

Show: