dimanche 29 octobre 2017

count_if third argument implementation using my own class

I am having trouble coding a function to correctly pass an argument to count_if of algorithm libary.

here is my code.

int range = count_if(empVect.begin(), empVect.end(), empVect.InRange(200,399));

inRange function implementation is:

bool Employee::inRange(double min, double max)
{
if (nIncome > min && nIncome < max)
return true;
return false;
}

compiler error: class "std::vector>" has no member "InRange"

I have a class of Employee with 2 strings and 3 double member variables. I have hard coded the vector creation in my main and need to display number of employees within a certain range of income. Required to use only count_if or lambda function as per assignment requirments. Thanks.

Aucun commentaire:

Enregistrer un commentaire