Loading lesson path
C++
C++ Functions focused on C++ Functions and related concepts.
A function is a block of code which only runs when it is called.
Information can be passed to functions as a parameter. Parameters act as variables inside the function.
You can also use a default parameter value, by using the equals sign ( = ).
Inside the function, you can add as many parameters as you want:
The void keyword, used in the previous examples, indicates that the function should not return a value. If you want the function to return a value, you can use a data type (such as int , string , etc…
You can also pass arrays to a function:
You can also pass a structure to a function.
Function overloading allows multiple functions to have the same name, as long as their parameters are different in type or number :
In C++, variables are only accessible inside the region they are created. This is called scope .
Recursion is the technique of making a function call itself.
A lambda function is a small, anonymous function you can write directly in your code. It's useful when you need a quick function without naming it or declaring it separately.