Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Lære Declaration vs Definition | Prototype | Functions
C++ Intermediate | Mobile-Friendly
course content

Kursinnhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

1. Data Types and Arrays
2. References & Pointers
3. Dynamic Memory
4. Functions

book
Declaration vs Definition | Prototype

Functions in C++ consist of 2 elements:

  • Declaration: the function's name with parameters (if they exist).

  • Definition: the function’s body.

python

The function declaration is also called the function’s prototype. The code body (the definition) can be defined separately. It’s a good rule to write before the main function prototypes of other functions to understand how many functions we have and which arguments it passes. After the main function, you should specify the function’s definitions:

python

It doesn’t affect your code if you specify prototypes or not. We won’t do this in further chapters since our code is still pretty simple and doesn’t need strict structurization.

question mark

Choose correct statements:

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 10

Spør AI

expand
ChatGPT

Spør om hva du vil, eller prøv ett av de foreslåtte spørsmålene for å starte chatten vår

course content

Kursinnhold

C++ Intermediate | Mobile-Friendly

C++ Intermediate | Mobile-Friendly

1. Data Types and Arrays
2. References & Pointers
3. Dynamic Memory
4. Functions

book
Declaration vs Definition | Prototype

Functions in C++ consist of 2 elements:

  • Declaration: the function's name with parameters (if they exist).

  • Definition: the function’s body.

python

The function declaration is also called the function’s prototype. The code body (the definition) can be defined separately. It’s a good rule to write before the main function prototypes of other functions to understand how many functions we have and which arguments it passes. After the main function, you should specify the function’s definitions:

python

It doesn’t affect your code if you specify prototypes or not. We won’t do this in further chapters since our code is still pretty simple and doesn’t need strict structurization.

question mark

Choose correct statements:

Select the correct answer

Alt var klart?

Hvordan kan vi forbedre det?

Takk for tilbakemeldingene dine!

Seksjon 4. Kapittel 10
Vi beklager at noe gikk galt. Hva skjedde?
some-alt