I tried using a lambda expression and count_if() to find the same string value in a vector, but it didn't work. The error message is:
variable 'str' cannot be implicitly captured in a lambda with no capture-default specified
std::vector<std::string> hello{"Mon","Tue", "Wes", "perfect","Sun"};
for (unsigned int i = 0; i < hello.size(); i++)
{
int n=0;
std::string str=hello[i];
n=std::count_if(hello.begin(),hello.end(),[](std::string s){return s==str;});
std::cout<<n;
}