和,或不与&,|| 、! [英] and, or, not versus &&, ||, !

查看:96
本文介绍了和,或不与&,|| 、!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,这是有效的C ++:

Yes, this is valid C++ :

if (false or (true and not false)) ...

其他,例如bitandxor.在C语言中,它们曾经是宏,但是现在是关键字!您甚至可以使它们超载!那为什么有人会教或写类似的东西呢?

Among others such as bitand and xor. In C, they used to be macros, but now they are keywords ! You can even overload them ! Then why would someone ever teach or write something like :

if (false || (true && !(false))) ...

为什么没人使用它们?

推荐答案

因为它们不允许在不包含其他头文件的情况下混合使用C/C ++代码,因此对于程序员而言鲜为人知,并且尚不清楚and是否是短路或按位版本.

Because they don't allow mixed C/C++ code without including additional header files, are less known to programmers, and it's not immediately clear whether and is the short-circuit or bitwise version.

这篇关于和,或不与&,|| 、!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆