Function Call Operator: ()
This documentation is archived and is not being maintained.

Function Call Operator: ()

Grammar

postfix-expression :
postfix-expression ( [argument-expression-list ] )

A postfix-expression followed by the function-call operator, ( ), specifies a function call. The arguments to the function-call operator are zero or more expressions separated by commas — the actual arguments to the function.

The postfix-expression must evaluate to a function address (for example, a function identifier or the value of a function pointer), and argument-expression-list is a list of expressions (separated by commas) whose values (the arguments) are passed to the function. The argument-expression-list argument can be empty.

The postfix-expression must be of one of these types:

  • Function returning type T. An example declaration is
    T func( int i )
    
  • Pointer to a function returning type T. An example declaration is
    T (*func)( int i )
    
  • Reference to a function returning type T. An example declaration is
    T (&func)(int i)
    
  • Pointer-to-member function dereference returning type T. Example function calls are
    (pObject->*pmf)();
    (Object.*pmf)();
    

Example

The following example calls the standard library function strcat with two arguments:

// expre_Function_Call_Operator.cpp
// compile with: /EHsc
#include <iostream>
#include <string>
using namespace std;
int main() {
   char s1[ 20 ] = "Welcome to ";
   char s2[ ] = "C++";
   strcat( s1, s2 );
   cout << s1 << endl;
}

See Also

Postfix Expressions | C++ Operators | Operator Precedence and Associativity | Function Call (C Reference) | Function Declarations

Show:
© 2016 Microsoft