rckinesis wrote: |
---|
"What is the problem if I don't use it." |
A smart compiler will optimise it way, which basically means the compiler will simply discard the variable. However,
KillBonus will not allocate any memory in this case, so you would not notice its absence.
rckinesis wrote: |
---|
"what is the need of using "const"." |
const is an abbreviation for
"constant". As its name implies, it protects a variable from modification. Once a constant variable has been declared, its value cannot change, unless you screw the compiler to work around it.
const can be used for optimisation purposes. In computers, resides ROM (Read-Only Memory). This is an area of memory which can only be read from. If a variable is declared constant, the compiler
can place it in ROM, but it doesn't have to. ROM memory is relatively quick as a result.
My rule of thumb is this:
"If it never needs to change, declare it constant."
Wazzak