- They let you reuse an arbitrary block of code throughout your application.
- Are code blocks that are unrelated to an object / class, just inherited from c.
- Has no implicit arguments - everything it needs must be passed in.
- It does not alter the state of the object.
- Use if the code is used frequently within a given class, or throughout the project, that it warrants being generalized.
- Use if it has no side-effects or context dependancies (none of that void *context mess).
--------------
Example:
RETURN_TYPE NAME(TYPE PARM-NAME, TYPE PARM-NAME...) {}
int foo(int a, int b) {
return a+b;
}
// call
int ab;
ab = foo(a, b);