Suppose there is an object which contains some data members, like this:
class MyObject {
   int age;
   string name;
   bool is_cool;
   …
   get(string member_name);  // returns the value of member
}; 
and now there is a MyIterator object by which I could iterate over all the MyObject, and during which I want to get some of the data members of MyObject, like the pseudo code below:
get_members(vector<string> member_names, vector<*> &output) {
  MyIterator it;
  while (it.next_myobject()) {
    for (name in member_names) {
       output.push_back(it.get(name))
    }
  }
}
My problem is, I don’t know how I could implement this idea, but if I only get 1 data member, I know how to implement this by defining a template function, like this:
template <typename T>
get_member(string member_name, vector<T> &output) {
  MyIterator it;
  while (it.next_myobject()) {
    output.push_back(it.get<T>(member_name));
  }
}
Give me some help :-)