Functions
Defining and Calling Functions
A function is a package of work named so we can perform the same steps as many times as needed. Once declared, it may be called from anywhere in the program usi…
Parameters and Return Values
Parameters and return values change functions from a fixed piece of code that does one thing into something that receives some data, does something to it, and r…
Pass by Value
When you call a function, every argument you provide is copied into its corresponding parameter. That's pretty much the entire story with pass by value. The par…
Function Declarations and Definitions
A function needs to be known to the compiler before it can be used. In C++, there are two ways for the compiler to learn about a function: through a declaration…
Default Arguments
A default argument allows the caller to omit a parameter. The compiler automatically fills in a missing value so that the function still receives the full compl…
Function Overloading
Functions that do roughly similar work sometimes need to accept different data types. Duplicating a name for each version can get very cumbersome very quickly.…
Recursion
A function can call itself. That is recursion. All function calls get their own fresh set of arguments and local variables, just as if a different function enti…
Static Local Variables
Regular local variables, upon entry into a function, are generated. Upon exit of the function, they are terminated. Each execution of the function represents a…
inline and constexpr Functions
When a function is called, it is necessary to: save the registers, set up a new stack frame, make the function call, and perform the opposite at the end. With s…