Sep 9, 2011 at 10:53am UTC
You have a list of pointers, but you're trying to add a student object to it.
Sep 9, 2011 at 11:08am UTC
thank you :)
another problem on almost the same function:
1 2 3 4 5 6 7 8 9 10 11 12 13
void Library::addStudent(const Student& student){
try {
list<Student>::iterator it;
it = find(students.front(),students.back(),student); // cant assign to it!
if (it == student.back())
throw DuplicateStudentAddind(student.getId());
students.push_back(student);
return ;
}
catch (DuplicateStudentAddind& e){
cout << e.what() << "(id=" <<e.getIndex() << ")" << endl;
}
}
Last edited on Sep 9, 2011 at 11:11am UTC
Sep 9, 2011 at 11:12am UTC
front() and back() return a reference to the first and last element, respectively.
However, find needs iterators, which you get with begin() and end().
Sep 9, 2011 at 11:23am UTC
can you show me the changes that i need to enteR ?
Sep 9, 2011 at 11:25am UTC
Replace front with begin and back with end.