I can use the remove_if function with the test() function below. However, when I try to pass an object to remove_if, I get the error mentioned in this post's title. I personally think the error has something to do with variable/function scope.
my code:
#include "Student_info.h"
#include <string>
#include <vector>
#include "Grade_gen.h"
#include <algorithm>
#include <iterator>
#include <list>
using std::vector; using std::remove_if;
bool Grade_gen::has_passed(Student_info& student){
if (student.grade() > 60)
{
return true;
}
return false;
}
bool test(Student_info& student)
{
return true;
}
std::list<Student_info>::iterator Grade_gen::process_students(std::list<Student_info>& students)
{
remove_if(students.begin(), students.end(), has_passed);
// this is just to test the scope of the functions in the class, they work.
std::list<Student_info>::iterator b = students.begin();
has_passed(*b);
return b;
}
#include "Student_info.h"
#include <string>
#include <vector>
#include <list>
class Grade_gen
{
public:
std::vector<Student_info> students;
bool has_passed(Student_info&);
std::list<Student_info>::iterator process_students(std::list<Student_info>&);
private:
};