Programmer's Wiki
Advertisement

A dynamic array is a resizable array data structure that can be dynamically resized as items are added to or removed from it.

As with static arrays, it allows O(1) random access. An advantage is that it also allows addition at the end, until it reaches a certain capacity, in which case it reassigns a new capacity and reallocates itself.

Implementations[]

C++[]

Dynamic arrays are implemented using vectors. In C++, vectors are part of the STL. They can be accesed by including vector.h, and are in the 'std' namespace;

#include <vector>

int main(void)
{
  std::vector<int> myVec;
  return 0;
}
16px-Pencil.png
Advertisement