c++ functions, methods, procedures

Functions in C++

Depending on the programming language, different names are used for functions. In some programming languages a distinction is made between functions that return a value as the result of a calculation and routines that only execute code. The latter are also known as procedures. However, functions are used in the C++ programming language.

A function is a block of code that performs some operation. A function can optionally define input parameters that allow callers to pass arguments into the function. A function can optionally return a value as output. Functions are useful for encapsulating common operations in a single reusable block, ideally using a name that clearly describes what the function does.

The function can be called or used from any number of places in the program. The values passed to the function are the arguments, whose types must be compatible with the parameter types in the function definition.