1

I'm currently learning about the bool type and wondering if there is a rule when we are comparing a bool variable with a different type. In that case, both conversions (var -> (int)) and (num -> (bool)) are plausible. Is there a rule that works for int and double in this context?

Here's a block of code to illustrate what I mean:

...
bool var = true;
int num = 5;

if (var == num)
    std::cout << "Equal" << std::endl;
else
    std::cout << "Not Equal" << std::endl;
...

nocomment
  • 129
  • 6

0 Answers0