Characteristics of Variables
Every variable has at least three
characteristics.
- Name: used to access the data in your code.
- Type: used to determine the amount of memory
required to store the variable, the representation or
interpretation of the bits stored in memory at that
location, and the operations that are legal on that
memory location.
- Value: the meaning of the bits
stored at the memory location selected by the compiler,
when interpreted according to its type.
When you define a variable in a C++ program, the compiler makes
sure that the variable is allocated
enough memory
to hold a value of that type. Here's an example:
int a = 3; // name->a, type->int, value->3
auto b = 3.14159; // name->b, type->double, value->pi
cout << a << endl; // print value
cout << b << endl; // print value