Guided Notes

Functions

Declaring and defining functions, parameters and return values, default arguments, overloading, recursion, and lambdas.

Defining functions

Slide 1 / 5

double area(double width, double height) { return width * height; }

• Return type, name, parameters, body. • void means nothing is returned. • A function must be declared before it's used — define it above main, or declare a prototype first: double area(double width, double height); • In larger programs, declarations go in header files (.h) and definitions in .cpp files.

← References & Pointers