Logical AND and OR operators: short-circuit evaluation 小灰灰 2022-01-05 15:49 203阅读 0赞 From C++ Primer: The logical AND and OR operators always evaluate their left operand before the right. The right operand is evaluated only if the left operand does not determine the result. This evaluation strategy is often referred to as "short-circuit evaluation." A valuable use of the logical AND operator is to have expr1 evaluate to false in the presence of a boundary condition that would make the evaluation of expr2 dangerous. As an example, we might have a string that contains the characters in a sentence and we might want to make the first word in the sentence all uppercase. We could do so as follows: string s("Expressions in C++ are composed..."); string::iterator it = s.begin(); // convert first word in s to uppercase while (it != s.end() && !isspace(*it)) { *it = toupper(*it); // toupper covered in section 3.2.4 (p. 88) ++it; } 转载于:https://www.cnblogs.com/taoxu0903/archive/2009/02/16/1392084.html
相关 【2023最新】Kotlin基础教程 Kotlin Basics 2 第二阶段:Sold! 2.10 【布尔和逻辑运算】Boolean and logical operations 【2023最新】Kotlin基础教程 Kotlin Basics 文章目录 【2023最新】Kotlin基础教程 Kotlin Basics Love The Way You Lie/ 2024年03月25日 22:04/ 0 赞/ 60 阅读
相关 Jmeter(十九)Logic Controllers 之 Module Controller and Include Controller Module Controller —模块控制器 测试计划设置“独立运行没每个线程组” ![在这里插入图片描述][watermark_type_ZmFuZ3po 青旅半醒/ 2022年12月06日 01:34/ 0 赞/ 138 阅读
相关 Logical AND and OR operators: short-circuit evaluation From C++ Primer: The logical AND and OR operators always evaluate their left operand be 小灰灰/ 2022年01月05日 15:49/ 0 赞/ 204 阅读
还没有评论,来说两句吧...