我在大型代码库中浏览一些 VC++ 代码时遇到了这个:
if (nState & TOOL_TIPS_VISIBLE)
nState &= ~TOOL_TIPS_VISIBLE;
else
nState |= TOOL_TIPS_VISIBLE;
break;
C++中有&=或|=这样的运算符吗?它有什么用?
它是否等同于 nState = nState & ~TOOL_TIPS_VISIBLE
?
最佳答案
x &= y
与 x = x & y
相同
x |= y
与 x = x | 相同y
关于c++ - 什么是 &= 和 |=,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8006410/