The output of cout << 1 && 0; [closed]

吃可爱长大的小学妹 提交于 2019-11-27 23:30:39
Smit Ycyken

It's all about Operator Precedence.

The Overloaded Bitwise Left Shift Operator operator<<(std::basic_ostream) has a higher priority than the Logical AND Operator &&.

#include <iostream>
int main() {
    std::cout << (1 && 0);
    return 0;
}

If you are not 146% sure about the priority of an operator, do not hesitate to use brackets. Most modern IDEs will tell you if you don't need to use them.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!