标签: c++ boolean
考虑以下c ++代码
bool p = false, q = false, r = true; bool another = p && q; cout << another; // another =false now cout << another || r; //false || true should be true
编译器输出为0(false)但如何输出。我希望它为1(真)
感谢
答案 0 :(得分:4)
<<运算符的higher precedence不是||,因此编译器会将其解释为
<<
||
(cout << another) || r;