什么是逗号操作呢? [英] What does the comma operator do?

查看:125
本文介绍了什么是逗号操作呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是以下code用C做/ C ++?

What does the following code do in C/C++?

if (blah(), 5) {
    //do something
}


推荐答案

逗号操作者施加和值5被用于确定条件的真/假

Comma operator is applied and the value 5 is used to determine the conditional's true/false.

它将执行布拉赫()和得到的东西回来(presumably),那么逗号运算符采用和5将是用于确定为前pression真/假值的唯一的事情

It will execute blah() and get something back (presumably), then the comma operator is employed and 5 will be the only thing that is used to determine the true/false value for the expression.


注意,运营商可能过载的胡说()函数(未指定)的返回类型,使结果不明显。

Note that the , operator could be overloaded for the return type of the blah() function (which wasn't specified), making the result non-obvious.

这篇关于什么是逗号操作呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆