0
Why would İ prefer to use a variable rather than a constant?
6 Respostas
+ 3
A constant is generally used in a program wherein you don't want to change its value throughout the execution of the main program, or by any of external functions accidentally, as in some cases. It gives advantage as in whenever a part of code tries to change its value, it reports an error.
+ 1
i.e. pi number, it never changes so it should be a constant
+ 1
an other advantage is that this "variables" are located in program memory and not in ram memory
0
I think it's because you can't change a const value after initializing
0
when you set it as a constant, there's less chances that another part of your program alters it's value... so it reduces the chances of getting errors...
0
Would you ever need a constant in a game?