C ++二进制运算符的优先顺序 [英] C++ Binary operators order of precedence
本文介绍了C ++二进制运算符的优先顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++中测试的以下参数是什么顺序?
In what order are the following parameters tested (in C++)?
if (a || b && c)
{
}
应用程序,我讨厌它,我想添加一些括号只是为了澄清排序。但我不想添加括号,直到我知道我将它们添加到正确的地方。
I've just seen this code in our application and I hate it, I want to add some brackets to just clarify the ordering. But I don't want to add the brackets until I know I'm adding them in the right place.
编辑:接受的答案&后续
Accepted Answer & Follow Up
此链接包含更多信息,但尚不完全清楚。看来||和&&
This link has more information, but it's not totally clear what it means. It seems || and && are the same precedence, and in that case, they are evaluated left-to-right.
http://msdn.microsoft.com/en-us/library/126fe14k.aspx
推荐答案
从这里:
a || (b && c)
这是默认优先级。
这篇关于C ++二进制运算符的优先顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文