You are here

Postfix Increment

10 February, 2015 - 10:38

Postfix increment says to use my existing value then when you are done with the other operators; increment me. An example:

int oldest = 44; // variable set up with initialization   then later on in the code age = oldest++; 

The first use of the oldest variable is an Rvalue context where the existing value of 44 is pulled or fetched and then assigned to the variable age; then the variable oldest is incremented with its value changing from 44 to 45. This seems to be a violation of precedence because increment is higher precedence than assignment. But that is how postfix increment works within the C++ programming language.