defined by types of input parameters, its name, type of return value, and algorithm that computes return value from input values
example:
int add(int a, int b) {
return a+b;
}
when a function is called, thread of execution continues within code of function
as soon as it returns, code that called the function continues a function returns if:
a void function is allowed to reach end of its code block
a function that has a return value must reach a return statement or throw an exception
parameters in declaration of function are called formal parameters parameters in call of function are called actual parameters
Rules of thumb:
pass-by-value:
void print(vector<double> v) {}
pass-by-const-reference
void print(const vector<double>& v) {}
pass-by-reference
void init(vector<double>& v) { v[2]=2; }