+ 2
I took the example code the lesson gave me, took out the "const" and it still worked.
So why do we even need const?
2 Respuestas
+ 8
const makes a variable that cannot be changed while the program runs. Ex: If you want a program to only receive 5 inputs, you can make a const like NUM_INPUTS, and use it in place of 5.
If you ever want to change that amount, it's easier to reassign the const than having to find every instance of 5 and changing it.
+ 2
Const declarations also help the compiler produce faster code.