In this module we learn about functions!
Functions in the C++ programming language are like
Some languages use other terminology for functions. e.g. Pascal has 'procedures' along with functions for example, and other languages use the terminology 'subroutine'. While languages may also offer slightly different semantics to how these different keywords are used, the idea of breaking a program into smaller 'routines' can help make programs more understandable.
Function overloading is a type of 'polymorphism'. Polymorphism means 'many forms'.
e.g.
// Example function that can add integers
int add(int a, int b){
return a+b;
}
// Example function that can add floating point numbers
float add(float a, float b){
return a+b;
}
// Example function that can add two std::string
// Note: We would probably better call this 'concatenate', but
// I think you get the idea. Also, we'll have to look into
// 'overloading the +' operator to handle the rules of
// what it means to add two strings together.
std::string add(std::string, std::string){
return a+b;
}
C++ functions support recursion as you may have seen in other functions.
Historically this was called 'call by copy' or 'call by copy restore' which may be a slightly more realistic name.
Pass in parameters by 'reference'. Can think of a 'reference' as an alias, in other words, it's something that already exists and we can make use of.
Talk about how the function call stack works