To create an array of strings, this works:
std::string array[] = {
"first",
"second",
:
"last"
};
If I try to do the same with vectors, this will not work:
std::vector<int> array[] = {
{1, 2},
{3, 4, 5}
:
{9}
};
I get that "non-aggregates cannot be initialized using a list of initializers."
What is the correct syntax for initializing an array of vectors?
Note that I need to do this at a time, and not use the vector member functions to populate the vectors intone at a time (because I'm trying to set up a file that will create an array at compile time based on the initialization numbers, so calling the member functions in this case does not help).
source
share