Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is C++ function call an expression?

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.

like image 820
Troskyvs Avatar asked Jul 04 '16 08:07

Troskyvs


People also ask

Is function call an expression?

A function call is an expression containing the function name followed by the function call operator, () . If the function has been defined to receive parameters, the values that are to be sent into the function are listed inside the parentheses of the function call operator.

Is calling a function a statement?

A function call is an expression. Since any expressions is also an expression statement, that means a function call is also a statement.

Is a function call a postfix expression?

A function call is a postfix expression consisting of a function designator followed by parentheses. The order of evaluation of any expressions in the function parameter list is undefined, but there is a sequence point before the actual call.

Is a function call an operator?

The function call operator is denoted by “()” which is used to call function and pass parameters. It is overloaded by the instance of the class known as a function object. When the function call operator is overloaded, an operator function is created that can be used to pass parameters.


1 Answers

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.

like image 157
JBL Avatar answered Oct 30 '22 03:10

JBL