I want to write a program which reads names in a vector. After that it should read ages into another vector. (that's done) The first element of the name-vector should be connected to the first element of the age-vector, so if I use any kind of sort() function on the name-vector the age-vector gets sorted as well. Is there any way to realize this in an easy way?
 class Name_pairs {
public:
  //member functions
  int read_names();
  int read_ages();
  int print();
private:
  vector<double> age;
  vector<string> name;
};
int Name_pairs::read_names() {
  cout << "Please enter different names, you want to store in a vector:\n";
  for (string names; cin >> names;) {
    name.push_back(names);  
  }
  cin.clear();
  cout << "You entered following names:\n\t";
  for (int i = 0; i < name.size(); i++) {
    cout << name[i] << " \n\t"; 
  }
  return 0;
}
int Name_pairs::read_ages() {
  cout << "\nPlease enter an age for every name in the vector.\n";
  for (double ages; cin >> ages;) {
    age.push_back(ages);
  }
  return 0;
}
 
     
    