Part 47 – Post-Decrement Operator

This week we will address the post-decrement operator. Let's examine our code.

#include <iostream>

int main(void) {
    int myNumber = 16;
    int myNewNumber = myNumber--;

    std::cout << myNewNumber << std::endl;
    std::cout << myNumber << std::endl;

    return 0;
}

As we compile we see 16 and 15 printed out respectively.

We see that in this scenario myNewNumber does get decremented as myNumber-- takes the value of 16 and reduces it to 15.

Next week we will dive into the Debugging Post-Decrement Operator.

results matching ""

    No results matching ""