Let's say i have a lot of vectors :
vector<int> v1 = ...
vector<int> v2 = ...
...
vector<int> v1000 = ...
Let's pretend that you don't have to manage and name them individually and instead of v1
to v1000
you could write v[0]
to v[999]
which makes it easy to process all of them in a loop etc?
There are standard solutions for this:
- If you have a fixed number of these vectors:
std::array<std::vector<int>, 1000> v;
- If you may want to add/remove vectors in run-time:
std::vector<std::vector<int>> v(1000);
Now, if you for some reason would like to create vGlobal
with a copy of all the vectors in v
:
std::vector<std::vector<int>> vGlobal(v.begin(), v.end());