I need to write a function that takes in a vector of strings and a vector of integer indices and display just those elements in the vector of strings at the given indices.
For example, if the vector of integer indices contains 1 and 4 then the function will display the first and fourth element of the vector of strings.
#include <iostream>
#include <string>
#include <vector>
usingnamespace std;
int main()
{
// I have a thing called 'my_strings'. Its type is a vector of strings.
vector<string> my_strings;
// Let's add some strings to my thing.
my_strings.push_back( "Hello" );
my_strings.push_back( "world!" );
// Let's display the thing to the user.
for (size_t n = 0; n < my_strings.size(); n++)
cout << my_strings[ n ] << " ";
cout << endl;
return 0;
}
Your function should take two arguments (two things): the first is a vector of strings and the second is a vector of integers: