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

2019-04-04 23:17发布

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 ?

4条回答
一纸荒年 Trace。
2楼-- · 2019-04-05 00:12

Visual C++ does not support them.

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-04-05 00:14

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.

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-04-05 00:15

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

查看更多
5楼-- · 2019-04-05 00:17

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

查看更多
登录 后发表回答