Function
Argument
Value returned
Function call
Type cast
Function declaration
Formal parameter
Function definition
Function header
Function body
Return statement
call-by-value
#include<cmath>
abs(-3);
log(2.71828)
exp(2.71828)
exp(3);
static_cast<double>(age);
Most functions will take only the type of argument they are defined for.
The very common exception to the above is most arithmetic functions, which will accept arguments of type int, but will convert them to type double before evaluating.
The first argument to the function pow must be positive.
Complex arguments will be evaluated before functions are applied, so log(9/5) will return the natural logarithm of 1, which is 0. Similarly, static_cast<double>(9/5) will return 1.0, not 1.8.
A common mistake is passing arguments to a function in the wrong order. For example, if you have defined a function to evaluate cost with inflation as
double eventual_cost(double init_cost, double infl_rate, int num_years)
and you end up using the following command in your program:
eventual_cost (rate,cost,time);
your program will think that the first number is the cost and the second number is the inflation rate, since that is the order in which it is expecting inputs.