From the course: C++ Essential Training

Unlock the full course today

Join today to access over 24,000 courses taught by industry experts.

Functions

Functions

- [Instructor] A function is an atomic standalone block of code. It may or may not have parameters or return of value. Some languages distinguish between a function at a procedure. C++ makes no such distinction. This is func.cpp from chapter three of the exercise files. And this is a function definition. A function definition includes a return type. And here, it's void. The name of the function, here it is func. And a pair of parenthesis. And a block of code. It may optionally specify parameters inside the parentheses. This function has no parameters. And a return type of void means that it does not return a value. A function is called by using its name, following parentheses. So we see down here on line 16, the function is called. The function itself in the block, it simply says this is func. And main says, this is main. And then calls func. So, what we would expect when we run this, is it'll say this is…

Contents