I'm trying to insert the contents of one map to another. Here is the code:
std::map<std::string, int> Student::getGrades() const;
...
for(set<Student*, Cmp>::const_iterator it = s.begin(); it!=s.end(); ++it)
{
grades.clear();
grades.insert((*it)->getGrades().begin(), (*it)->getGrades().end());
for(map<string, int>::const_iterator itt = grades.begin(); itt!=grades.end(); ++itt)
{
if(itt->first == course && itt->second >= score1 && itt->second <= score2)
(*it)->display(cout);
}
}
s is a set that contains pointers to student objects and each student objects has a getGrades() method that returns a map. I'm trying to find grades that match grades that I have read in from a file and print the record corresponding to those grades. However, the insert method is giving me a seg fault. Any suggestions?