+ 2
wat is the use of const
4 Réponses
+ 5
with the const keyword you can make a variable(,parameters etc...) value not changeble. this helps prevent accidental value changes and makes the code more self-explanatory.
+ 1
To ensure that the values of important data cannot be changed by the code.
+ 1
for example you can define PI = 3.1415 and use it thorough your program.
0
to prevent any change for the variable; further the use of const provides the compiler to do better optimations (e.g. replace with literals)