New (C++) - Reallocating Memory Allocated By new

Reallocating Memory Allocated By new

In contrast to C's realloc, it is not possible to directly reallocate memory allocated with new. To extend or reduce the size of a block, one must allocate a new block of adequate size, copy over the old memory, and delete the old block. The C++ standard library provides a dynamic array that can be extended or reduced in its std::vector template.

Read more about this topic:  New (C++)

Famous quotes containing the word memory:

    And year by year our memory fades
    From all the circle of the hills.
    Alfred Tennyson (1809–1892)