Something like this:
void Roster::printDaysInCourse(string studentID)
{
float avg = 0;
int max = 3;
for (auto it : classRosterArray) {
int *daysInCourse = it->second->fetchDaysInCourse();
for (int x = 0; x < max; x++) {
avg += daysInCourse[x];
}
cout << "Student " << it->second->fetchStudentId() << "'s average number of days in each course is." << (avg / max) << "\n";
}
}
But you have a design problem in that you can't have two students with the same name in your roster. If you insist on a map, put the student ID as the key, instead of the value (
std::map<shared_ptr<Student>, string> classRosterArray;
). That overcomes the problem. But I'd recommend using a vector of shared_ptrs, or unique_ptrs, instead of an array or a map, because you don't have to use the 'first' and 'second' nomenclature. You can also go back to something closer to your original design and overcome the lack of duplicate names issue. You will have to learn how to use vectors, though, and revamp your Roster class to add and remove from the vector properly.