Category

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…

Jul 14, 2026 →

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…

Jul 14, 2026 →

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…

Jul 14, 2026 →

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…

Jul 14, 2026 →

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…

Jul 14, 2026 →

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.…

Jul 14, 2026 →

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…

Jul 14, 2026 →

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…

Jul 14, 2026 →

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…

Jul 14, 2026 →
About CppLearn

CppLearn is an interactive, free reference for modern C++. In each lesson, you'll find out how the language works, rather than just lines of code that you can copy and paste. We cover concepts starting from beginner lessons on fundamentals and proceed to templates, move semantics, smart pointers, and areas that usually trap or scare C++ learners.