I have two separate vectors of strings:
std::vector<std::string> vectorA;
vectorA.push_back("a1");
vectorA.push_back("\na2");
std::vector<std::string> vectorB;
vectorB.push_back("b1");
vectorB.push_back("b2");
I want to create an std::string vectorOutput which shows the following:
a1 b1
a2 b2
Now, the elements in vector A are defined in one class, while the elements in vector B come from another class and are read after some code logic happens. The vector sizes are identical. I would like to know what is the best way in C++ to create this new vectorOutput string? I was thinking of a loop which iterates over the elements of each vector and appends them to the vectorOutput, like:
for (int i = 0; i < vectorA.size() < i++)
{
vectorOutput += vectorA[i] + vectorB[i];
}
In my code these vectors have more elements than presented here. Is there another way to achieve this? Perhaps by creating enums or structs?