Search⌘ K

Declaring a Function

Explore how to declare functions in C++ by understanding return types, function names, and optional parameters. This lesson helps you grasp essential syntax to inform the compiler about your function's characteristics, preparing you to write and use functions effectively in your programs.

Function creation

In C++, function creation consists of the following two steps:

  • Function declaration
  • Function definition

Function declaration

Function declaration informs the compiler about:

  • The return type of function
  • The function name
  • The number of parameters and their data types.

The basic syntax for ...