Reputation: 15
for (std::string& request : recData.getReqest()) //recData is a vector
{
}
recData is a vector which stores objects of an X type, X class has a member variable which is "std::string request;" and as I iterate through the for loop I want all objects within recData to have their request member variable processed. Is this possible?
Upvotes: 1
Views: 66
Reputation: 118330
It's certainly possible, by changing the for
loop and using one extra statement:
for (auto &r: recData)
{
std::string &request = r.request;
// Here's your request, for your loop.
}
Upvotes: 1