From the course: Complete Guide to C++ Programming Foundations
Unlock this course with a free trial
Join today to access over 24,800 courses taught by industry experts.
Overview of functions - C++ Tutorial
From the course: Complete Guide to C++ Programming Foundations
Overview of functions
- [Instructor] We have been using functions in pretty much every example up to this point. Now it's time to take a closer look at functions and their many advantages. Functions provide modularity to your code. That's why virtually every programming language supports them. Functions are procedural blocks of code that return a value. They usually receive a fixed number of arguments of specific types, but some functions use a variable number of arguments. Now, there's a distinction between the terms parameter and argument. Arguments are the variables or constants that are sent to the function when it is called. Parameters, on the other hand, are the variables in the function that take the values of their arguments. Also, functions may be global or they may be members of a class, which is the same we call methods in Java and Python. Let's break down the anatomy of a function. A function in C++ typically consists of a return type, a name, a parameter list, and the function body. The return…