The book asks me to do the following:
Note that the function from the previous exercise and the functions from §6.2.2/113 and
§6.2.3/115 do the same task. Merge these three analysis functions into a single function.
the three functions are:
double average_analysis(const vector<Student_info>& students)
{
vector<double> grades;
transform(students.begin(), students.end(),
back_inserter(grades), average_grade);
return median(grades);
}
double median_analysis(const vector<Student_info>& students)
{
vector<double> grades;
transform(students.begin(), students.end(),
back_inserter(grades), grade_aux);
return median(grades);
}
double optimistic_median_analysis(const vector<Student_info>& s)
{
vector<double> grades;
transform(s.begin(), s.end(), back_inserter(grades), optimistic_median);
return median(grades);
}
The only thing that differs if the parameter(which are functions) the function uses in the transform part
Can anyone give me any hints on how to do what he asks ?
is there a way to make that function calling "generic" so I can choose it later ... using only one analysis function ?