Declaring variables with const

Like in mathematics it makes the numbers a constant.

I think that const probably turns a variable into a constant, i.e. it cannot be changed.

it makes it so thata the variable cannot be changed to any other value during code execution

I would say const is meant to make a variable into a constant variable insuring it stays the same down the line.

Im guessing it forces the identifier to keep our value the same even if we do later try to change it elsewhere.

If a variable is a value that changes, a const (constant) is a value that does not change.

If we later try to change the value, it would give ERROR or it would not be possible

It will lock the variables value to the one you set when you declare it.

IMHO it fixes the value and makes it constant, in other words - unchangeable. Useful in applications where the value of something is predetermined throughout problem (like Plank constant or Pi number)

I think const keeps the variable from changing to a new value.

The value never changes

Const preceding the declaration of a variable refrains that variable from being changed in the future.

When applying const to the beginning of a int it changes to a constant variable through the code. Say when you place a declared variable above where the variable was declared it will still be recognized because the code searches for const first then proceeds down.

what I think const is that is the shorter way of saying constant, but I don’t know how it will affect the code

I believe ‘const’ means that the variable is ‘constant’ or ‘consistent’ and no matter what following changes are attempted, it will not change.

I think const is short for constant. So if we put const before the variable then it will remain constant and not change.

const seems like a short form of constant which would mean that it doesnt allow the variable to be changed. Turns the VARIABLE into a CONSTANT

I think when we will try to change the value of that variable having const as it’s prefix, still the value of that particular variable will remain the same. And the value will remain the same till the end of the program.

I think that const ensures that the variable value cannot be changed after initialization.

Const stands for constant and the value cannot be chanced after initialization, hence it being a constant.

const being short for constant, i think it will keep the variable constantly the same value we assign originally. So, no matter what, it will always come back to the same value.

Privacy & Terms