I have a class Student which contains a name, a private int regNo and a private map which is a store of their marks. This is the constructor.
Student::Student (string const& name, int regNo):Person(name), regNo(regNo)
{
map<string, float> marks;
}
I need to write a function that takes two parameters a collection of students mine are stored in a vector, and a float that the user provides, the function should output the name of the student, and the min, max and average marks when their average is greater than a user provided input. My problem is what's the easiest way to get all the values (marks) out of the map? as in accessing the map and getting all of the marks, do I need a function in the student class that returns a mark, how's best to do that? Thanks.
You can create a function that returns a vector of all the marks
vector<string> vec;
for( map<string,float>::iterator it = marks.begin(); it != marks.end(); ++it)
{
vec.push_back(it->first);
}