4.5. Summary
- 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 ]).
- Defining a new meaning for an already existing operator (such as the arithmetic operators plus “+” or times “*”) is called overloading the operator.
- The operators ::, #, ., and ? are reserved and cannot be overloaded.
- Some operators such as =, [], () and -> can only be overloaded as member functions of a class and not as global functions.
Next Section - 4.6. Glossary