Is C++ function call an expression?

梦想的初衷 提交于 2021-02-07 17:32:44

问题


A function produces a result, can be used as argument of another function parameter. So, is a function call like:

f(1,2,3)

be considered as an "expression"? Thanks.


回答1:


The C++ standard (N3376, §5.1) specifies an expression as:

An expression is a sequence of operators and operands that specifies a computation. An expression can result in a value and can cause side effects.

Further in the same section (§5.2.2):

A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of expressions which constitute the arguments to the function.

In short, yes.




回答2:


According to 5.2.2 [expr.call] paragraph 1 of ISO/IEC 14882:2014, a function call is a [postfix] expression:

A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of initializer-clauses which constitute the arguments to the function. ...



来源:https://stackoverflow.com/questions/38180381/is-c-function-call-an-expression

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