and, or, not versus &&, ||, ! [closed]

大城市里の小女人 提交于 2019-12-05 15:50:24

问题


Yes, this is valid C++ :

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

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))) ...

Why is nobody using them ?


回答1:


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.




回答2:


Why nobody? Some use them. Others think that symbols are more readable than words.




回答3:


Visual C++ does not support them.




回答4:


People just don't know about them(I didn't until now).



来源:https://stackoverflow.com/questions/5282692/and-or-not-versus

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!