std::vector

Applies to: cpp

std::vector is C++'s dynamic array: a contiguous, resizable sequence that manages its own memory (RAII). Add with push_back, index with [], and ask its length with .size(). It is the default "list of things" in C++.

std::vector<double> v;
v.push_back(1.5);
v.push_back(2.0);
v.size();            // 2

See also: array, template, reference