Const code

i think const means constant and it makes our code constant

yeah I think

Yes, const means constant. It’s a promise to say “I will never change this variable” or “this function will not change the value of a variable that belongs to the function’s class.”

It’s a great way to enforce the idea that a variable shouldn’t change, and if you try to, you get an error, which is safer than relying on memory that a particular variable shouldn’t change.

It’s also pretty handy when all you need to do is look at a variable and know that, if it’s const, it’ll never change. When looking through code trying to debug an issue and see what changed and how, you can safely know that the const variables don’t change.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms