Learn C++: Functions
Write flexible, reusable C++ functions: parameters and return values, silent conversions, declarations, headers and include guards, inline and the one-definition rule, scope, default arguments, overloading and templates, with module quizzes and a unit-converter project.
- Beginner level
- 4 modules
- 16 lessons
- 71 tasks and questions
Syllabus
01FunctionsPackage code into reusable functions. Define and call them, pass parameters by value, return results, and learn what the compiler converts silently on the way in and out.4 lessons
02Declarations, Headers and ScopeDeclare functions before they are defined, split a program across header and source files, guard headers against double inclusion, define small functions in headers with inline, and keep names in the right scope.5 lessons
03Flexible FunctionsMake one function name do more: default arguments, overloading with its resolution and ambiguity rules, and function templates that work for any type.4 lessons
04PracticeSharpen your function-writing skills with short code challenges, then combine several functions into a unit-converter project.3 lessons