bool isSomething(string val, string lst) {
for(auto c = 0; c < lst.size(); c++) {
if(val == c) {
return true;
}
}
return false;
};
Code produces the following error:
error: invalid operands to binary expression ('std::__ndk1::string' (aka 'basic_string<char, char_traits<char>, allocator<char> >') and 'int')
if(val == c) {
~~~ ^ ~
I tried to change the return type, it didn’t help, I’m rewriting the code, and I don’t know.
I think we should overload the == operator, but I’m not sure if it’s possible, and I don’t quite know how to do it.
>Solution :
try this:
if(stoi(val) == c)
It seems that you’re trying to compare string and an integer