'Comparing Bool with Integer or Double [duplicate]

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;
...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source