Course Content
Introduction to C++
Functions With Arguments
A function with a parameter (argument) is a function that has to work with an object "from the outside".
Note
A function argument is a local variable created and exists only in the current function.
For example, let's create a function that divides any integer by 2:
To use such a function, you need to call it and pass an argument to it:
Here is an example:
main.cpp
You can pass multiple arguments to a function:
main.cpp
func(5, 7)
– calling a function and passing arguments to it.
Arguments are passed with commas (,
).
You can also pass arrays:
main.cpp
Section 5.
Chapter 4