Compile errors for no known bool conversions, though function and arguments is not a bool

Hello! I’m having compile errors about a bool conversion error, though there is no bools in any of my code, and the return type of my function which the code resides in is also not a bool, either.

int path(std::string input, int type) {
  if (type == 0 and input == "L") {
    return 1; //player selected left
  } else if (type == 0 and input = "R") {
    return 2; //player selected right
  }
}

I’ve tried using && and and to make this code work, but it expects a bool conversion for the std::string input variable. I don’t know what’s causing the error, and I don’t want to switch the function to a bool so I can add more return numbers.
If anyone can help, that would be great, Thanks!!

Hi,
An ‘if’ condition will evaluate to a bool, as it will either be true or false.
I’ve not much experience of c++, but you only have a single = here;

input = "R"

That may be what is giving you an issue

Hope that helps

1 Like

Just noticed that, thank you very much!!!

2 Likes