Conteúdo do Curso
Introduction to C++ | Mobile-Friendly
Introduction to C++ | Mobile-Friendly
Constant
If you have a static variable that never changes and you want that nobody overrides your variable, use the const
keyword by declaration. It makes the variable unchangable (constsant).
For example:
The variable x
will always be 42 and nobody can change it. The following code would cause an error:
You should declare variables as constants if you are sure that they will probably never change:
Obrigado pelo seu feedback!