Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Introduction aux Pointeurs | Fondamentaux des Pointeurs
Practice
Projects
Quizzes & Challenges
Quiz
Challenges
/
C++ Pointeurs et Références

bookIntroduction aux Pointeurs

A pointer is a variable that stores the memory address of another variable. It allows direct manipulation of memory. Declaration and initialization of a pointer looks like this:

pointer.h

pointer.h

copy
1
int* p_Name = nullptr;
  • int: specifies the base type of the variable that the pointer will point to. In this case, it's an integer;

  • *: called dereference operator, returns the value stored at the address held by a pointer;

  • p_Name: the name of the pointer variable. You can choose any valid variable name;

  • nullptr: is a keyword that represents a null pointer, indicating that it is empty and doesn't point to anything.

Note
Note

Commonly, pointers are named with a prefix p_ as a naming convention signifying that the variable is a pointer.

Tâche

Swipe to start coding

  1. Declare and initialize pointer with a nullptr.
  2. Display a pointer for a chosen primitive data type.
  3. Make sure its name has p_ prefix.

Solution

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 1
single

single

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

close

bookIntroduction aux Pointeurs

Glissez pour afficher le menu

A pointer is a variable that stores the memory address of another variable. It allows direct manipulation of memory. Declaration and initialization of a pointer looks like this:

pointer.h

pointer.h

copy
1
int* p_Name = nullptr;
  • int: specifies the base type of the variable that the pointer will point to. In this case, it's an integer;

  • *: called dereference operator, returns the value stored at the address held by a pointer;

  • p_Name: the name of the pointer variable. You can choose any valid variable name;

  • nullptr: is a keyword that represents a null pointer, indicating that it is empty and doesn't point to anything.

Note
Note

Commonly, pointers are named with a prefix p_ as a naming convention signifying that the variable is a pointer.

Tâche

Swipe to start coding

  1. Declare and initialize pointer with a nullptr.
  2. Display a pointer for a chosen primitive data type.
  3. Make sure its name has p_ prefix.

Solution

Switch to desktopPassez à un bureau pour une pratique réelleContinuez d'où vous êtes en utilisant l'une des options ci-dessous
Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 1. Chapitre 1
single

single

some-alt