c++ - Unusual use of a Boolean expression -


this part of code base
code:

bool succ = true; //below place warning there  succ &= draw( e0.x, e0.y, e0.z, (e0.x + dir.x), (e0.y + dir.y), (e0.z + dir.z)); //------ //------ bool draw( float x, float y, float z, float p, float q, float r)   {     bool ret;     ret = fun(x,y,z,p,q,r);     return ret; } 

warning :

warning 514: unusual use of boolean expression info 1786: implicit conversion boolean (assignment) (int bool) 

i don't want increase line of code ,so doing logic in 1 line ...can me in resolving issue ...

you have &= there, these basic types equivalent to

bool succ = ...; succ = succ & draw(...); 

however bitwise & operator takes integer values, succ needs cast int in order compare using bitwise &. when use booleans should instead use

bool succ = ...; succ = draw(...) && succ; 

(as pointed out have change order here since && 1 of few places c++ lazily evaluating)

notice there no &&= operator.

edit: result of draw(...) needs cast int too...


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -