有人使用命名的布尔运算符吗?

2022-01-19 00:00:00 boolean c++

还是我们都坚持我们教过的&&, ||, !"怎么办?

Or are we all sticking to our taught "&&, ||, !" way?

对于我们为什么应该使用其中一个有什么想法吗?

Any thoughts in why we should use one or the other?

我只是想知道,因为有几个答案表明代码应该尽可能自然,但我没有看到很多带有and,or,not"的代码,而这更自然.

I'm just wondering because several answers state thate code should be as natural as possible, but I haven't seen a lot of code with "and, or, not" while this is more natural.

推荐答案

以前不支持这些.即使是现在,您也需要对某些编译器进行特殊切换以启用这些关键字.这可能是因为旧代码库可能有一些功能 ||名为and"or"not"的变量.

Those were not supported in the old days. And even now you need to give a special switch to some compilers to enable these keywords. That's probably because old code base may have had some functions || variables named "and" "or" "not".

相关文章