Skip to main content
Module 3 · Lesson 1 of 27/26 in the course~12 min
Module lessons (1/2)

Basic functions

Lesson preview5 hands-on exercises readyCourse C++ · Module 3 — Functions and References

Declare and define functions. Input parameters, return type and basic execution.

What you'll learn in this lesson

  • Decompose complex programs into pure, well-named functions (camelCase in C++).
  • Distinguish declaration (prototype) from definition to resolve the compiler's top-down reading order.
  • Leverage parameters with default values and function overloading on parameter signature.

Overview

Every function in C++ declares the return type, the name, and the parameter types in advance. The compiler checks every call exactly against this signature.

A function that returns a result ends with return expr;; a function that performs only actions (e.g. print or mutate) declares return type void:

Sections covered in this lesson

  1. 11. Definition and Basic Call
  2. 22. Declaration (Prototype) vs Definition
  3. 33. Parameters with Default Value
  4. 44. Function Overloading
  5. 5Practical exercises
  6. 6Check for understanding
Pro Lesson · Module 3 — Functions and References

Unlock "Basic functions" and the full Course C++ curriculum

Declare and define functions. Input parameters, return type and basic execution.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Course C++ plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.