Forcing value to boolean: (bool) makes warning, !! doesnt.

Posted by Newbie on Stack Overflow See other posts from Stack Overflow or by Newbie
Published on 2010-03-13T18:33:11Z Indexed on 2010/03/13 18:35 UTC
Read the original article Hit count: 83

Filed under:
|

I like (bool) way more, but it generates warnings. How do i get rid off the warnings?

I have code like:

bool something_else = 0;

void switcher(int val = -1){
    if(val != -1){
        something_else = (bool)val;
    }else{
        something_else ^= 1;
    }
}

Should i just do it like everyone else and use '!!' or make it somehow hide the warning messages when using (bool) ? Or is '!!' actually faster than (bool) ?

I would like to use (bool) and so i have to hide the warning, but how?

© Stack Overflow or respective owner

Related posts about c++

Related posts about boolean