C++ 23 · Containers and algorithms

Use a vector

A growable array. emplace_back constructs the element in place.

std::vector<int> v = {3, 1, 2};
v.push_back(4);
v.emplace_back(5);
std::cout << v.size() << ' ' << v.front() << '\n';

Official C++ 23 documentation

More containers and algorithms commands

All containers and algorithms commands · C++ 23 cheatsheet

Was this page helpful?