Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c++

logic

keyword

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 ?

like image 673
fouronnes Avatar asked Mar 12 '11 13:03

fouronnes


2 Answers

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.

like image 50
phihag Avatar answered Oct 15 '22 08:10

phihag


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

like image 36
Yakov Galka Avatar answered Oct 15 '22 06:10

Yakov Galka