I have a problem with the following code:
const std::vector < std::string > arr1 = { "a", "b", "c" };
const std::vector < std::string > arr2 = { "e", "f", "g" };
const std::vector < std::string > globaArr = { arr1, arr2 };
I need to initialize globalArr with the values: "a", "b", "c", "e", "f", "g" (in one dimension). I do not need to have a two-dimensional array. What am I doing wrong?
I can do something like this:
globalArr.push_back( arr1 ); // with the for loop inserting each value of arr1
globalArr.push_back( arr2 );
but here globalArr is no longer const :) I need the same type for all three vectors.
source
share