 Constant
Constant
If you have a static variable that never changes and you want that nobody overrides your variable, use the  const  keyword by declaration. It makes the variable unchangable (constsant).
For example:
const double x = 42;
The variable x will always be 42 and nobody can change it. The following code would cause an error:
const int x = 10;
x = 15;
You should declare variables as constants if you are sure that they will probably never change:
const int monthPerYear = 12;
const char firstAlphabetLetter = 'A';
Merci pour vos commentaires !
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Posez-moi des questions sur ce sujet
Résumer ce chapitre
Afficher des exemples du monde réel
Awesome!
Completion rate improved to 3.7 Constant
Constant
Glissez pour afficher le menu
If you have a static variable that never changes and you want that nobody overrides your variable, use the  const  keyword by declaration. It makes the variable unchangable (constsant).
For example:
const double x = 42;
The variable x will always be 42 and nobody can change it. The following code would cause an error:
const int x = 10;
x = 15;
You should declare variables as constants if you are sure that they will probably never change:
const int monthPerYear = 12;
const char firstAlphabetLetter = 'A';
Merci pour vos commentaires !