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';
C++ 23 · Containers and algorithms
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';
Was this page helpful?