To get our C++ program to run, we have to translate it into a machine language program, or let’s say an executable. To do this we need a couple of things.
Let’s start with a C++ compiler. To keep it simple for now, we’ll drop some intermediate steps and say that what the compiler primarily does is:
1. Assigning memory addresses to variables. This allows us to use names for variables, rather than having to keep track of the address of each variable ourselves.
2. Translating arithmetic and other operations (such as +, –, etc.) into the equivalent machine instructions, including the addresses of variables assigned in the previous step.
Each complete operation understood by the compiler is called a statement, and ends with a semicolon (;).
An example could be:
int age = 32;
This tells the compiler to make room for an integer in memory and assign the variable “age” the value of 5. This is called a “statement”. Values are assigned from right to left, so in case of:
age = age + 10;
The calculation of age + 10 is done before assigning the new value back into the already initialized age variable of type int.