Contenido del Curso
Introduction to C++
Introduction to C++
Identifiers
Each variable has its unique name - identifier. There’re some rules for naming variables:
- Names must start with a letter or underscore _ and contain only letters, digits, and underscores (no special characters or whitespaces).
- Names can be different because of the case (myDog and MyDog are two different variables).
- Reserved words such as
int
cannot be identifiers.
There are short names for variables such as x
and y
, and also descriptive names like monthIncome
or amountPerYear
. The good rule is to use descriptive names since it makes your code more clear and understandable.
In cases, you don’t want to define the type of the variable automatically by declaration you can use the auto
keyword. It infers the type from the value of the variable, so it’s necessary to initialize the variable when you define it.
¡Gracias por tus comentarios!