0

I have a vector(details) containing class objects, i am trying to use find_if to look for a record in the vector. I searched through some solutions on it on stackoverflow and tried out the solutions.

e.g How to use std::find/std::find_if with a vector of custom class objects?

but on the line of find_if it gives me error

expected primary-expression before "[" token
expected primary-expression before "const"

    std::vector<user> details;
    std::string name;
    std::cout << "Please enter a name\n";
    std::cin >> name;

    std::find_if(details.begin(), details.end(),
                   [&name](user const& userInfo)
                   {return userInfo.getName()==name;});

I am using Dev-C++.

Community
  • 1
  • 1
user3493435
  • 81
  • 1
  • 3
  • 11

0 Answers0