C++ short-circuiting of booleans

前端 未结 8 2015
生来不讨喜
生来不讨喜 2020-11-28 16:05

I\'m new to c++ and am curious how the compiler handles lazy evaluation of booleans. For example,

if(A == 1 || B == 2){...}

If A does equal

8条回答
  •  北荒
    北荒 (楼主)
    2020-11-28 16:29

    No it's not.

    Same with &&, if one is wrong, it doesn't bother evaluating the other one.

提交回复
热议问题