C ++二进制运算符的优先顺序

编程入门 行业动态 更新时间:2024-10-12 05:49:07
本文介绍了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.

msdn.microsoft/en-us/library/126fe14k.aspx

推荐答案

从这里:

a || (b && c)

这是默认优先级。

更多推荐

C ++二进制运算符的优先顺序

本文发布于:2023-11-06 03:52:27,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562654.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:顺序   运算符

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!