C++中'和','或'等关键字的目的是什么?

Mat*_*att 5 c++ operators keyword operator-keyword

以下关键字的目的是什么?

and      bitand   compl   not_eq   or_eq   xor_eq
and_eq   bitor    not     or       xor
Run Code Online (Sandbox Code Playgroud)

如果他们只是直接相当于:

&&       &        ~       !=       |=      ^=
&=       |        !       ||       ^
Run Code Online (Sandbox Code Playgroud)

Kyl*_*tan 13

http://en.wikipedia.org/wiki/Iso646.h

iso646.h "...定义了许多宏,它们允许程序员使用C语言的按位和逻辑运算符,这些运算符在没有头文件的情况下,无法在某些国际和非QWERTY键盘上快速或轻松地键入.

文件名是指ISO646标准,这是一个7位字符集,带有许多区域变体,其中一些具有重音字符代替C运算符使用的标点符号."

  • 在C++中,这些不是宏,而是"替代令牌",并且您不需要包含iso646.h. (6认同)
  • @RafaelBaptista`class foo {compl foo(){}};`不完全可读......但它有效. (4认同)

Raf*_*sta 7

这样你就可以编写疯狂的代码诗:

class jack
{
   jack();
   jack( jack & jill );
   jack& came_tumbling( int after );
   jack& fell( jack & jill ); 
   jack& operator &= ( jack & jill );
   jack& operator & ( jack & jill );
}

void to_fetch( int pail );

int a_pail;
int after;
jack broke_his_crown;
jack went_up_the_hill;
jack down;

jack and jill = went_up_the_hill;
to_fetch( a_pail ); // of water
jack fell( down and broke_his_crown 
and jill.came_tumbling( after ));
Run Code Online (Sandbox Code Playgroud)