Skip to main content
Contents
Dark Mode Prev Up Next Scratch ActiveCode Profile
\(
\newcommand{\lt}{<}
\newcommand{\gt}{>}
\newcommand{\amp}{&}
\definecolor{fillinmathshade}{gray}{0.9}
\newcommand{\fillinmath}[1]{\mathchoice{\colorbox{fillinmathshade}{$\displaystyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\textstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptstyle \phantom{\,#1\,}$}}{\colorbox{fillinmathshade}{$\scriptscriptstyle\phantom{\,#1\,}$}}}
\)
Section 4.5 Summary & Reading Questions
Like Python, C++ supports the use of functions.
In C++, a function definition requires a name, a group of parameters, a return type, and a body.
Non-fruitful functions in C++ must contain the keyword
void
in its function definition.
You can pass variables by value as well as by reference in C++ functions. Passing by reference utilizes the use of pointers.
Pass by reference is useful when you require a function to return multiple variables.
To pass an array to a function you need to use an array parameter. The array parameter is denoted by the array variable name followed by set of square brackets ([ and ]).
Reading Questions Reading Questions
1.
2.
You have attempted
of
activities on this page.