#include <iostream>
int main(int argc, char* argv[])
{
unsigned long mask = 0x00000001;
unsigned long mask1 = 0x00000001;
unsigned long mask2 = 0x00000010;
if ((mask and mask1) && (mask and mask2))// CONDITION_1 is True.
std::cout << "Ohhhhhhh..." << std::endl;
if ((mask & mask1) && (mask & mask2)) //CONDITION_2 is False.
std::cout << "No Output..." << std::endl;
return 0;
}
我认为 CONDITION_1 和 CONDITION_2 都是 False,但我的想法显然是错误的,为什么 'and' 和 '&' 在 C++ 中不一样?
最佳答案
and
和&&
是一样的。这是合乎逻辑的。 &
是按位与。
关于c++ - C++ 中的 'and' 和 '&' 有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17682335/