Purpose of const

I’m not entirely sure what you would call const, a qualifier to the variable type maybe, but I believe it prevents the variable in question from being modified later in the code which may prevent mistakes and errors in a large program, especially one that is being worked on by multiple people.

1 Like

That’s it. const is useful if you have something you need to refer to in multiple places without putting the value in each line of code. This then makes it easier to change that value if necessary.

Privacy & Terms