For a complete table of contents of all the lessons please click below as it will give you a brief of each lesson in addition to the topics it will cover. https://github.com/mytechnotalent/Reverse-Engineering-Tutorial
The next stage in our journey is that of the pre-increment operator.
Let’s examine our code.
#include <iostream> int main(void) { int myNumber = 16; int myNewNumber = ++myNumber; std::cout << myNewNumber << std::endl; return 0; }
To compile this we simply type:
g++ example9.cpp -o example9
./example9
We see 17 printed to the screen.
Let’s break it down:
We create a variable myNumber = 16 to which we create another variable myNewNumber which pre-increments the value of myNumber. We see that when we execute our code it shows 17.
When we pre-increment the value of the variable is incremented before assigning it to another variable. For example myNumber is 16 so it gets incremented before being assigned to myNewNumber so therefore we get 17.
Next week we will dive into Debugging Pre-Increment Operator.