Accessing of Functions in C++

A function can be accessed (i.e., called) by specifying its name, followed by a list of arguments enclosed in parentheses and separated by commas as shown below.

If the function call does not require any arguments, an empty pair of parentheses must follow the name of the function as shown below.

The function call may be a part of a single expression (such as an assignment statement), or it may be one of the operands within the more complex expression as shown below.

The arguments appearing in the function call are referred to as actual arguments, in contrast to the formal arguments that appear in the first line of the function definition.

In normal function call, there will be one actual argument for each formal argument. The actual arguments may be expressed as constants, single variables or more complex expressions. However, each actual arguments must be of the same data type as its corresponding formal argument.

Consider the below function definition:

We can access the above defined function as shown below:

In the above function call, values “2” and “3” are called actual arguments.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *