You are here

Basic Concept

10 February, 2015 - 10:32

Within the C++ programming language the increment and decrement are often used in this simple generic way. The operator of increment is represented by two plus signs in a row. Examples:

counter = counter + l; 
counter += l; 

As C++ statements, the four examples all do the same thing. They add 1 to the value of whatever is stored in counter. The decrement opereator is represented by two minus signs in a row. They would subtract 1 from the value of whatever was in the variable being decremented. The precedence of increment and decrement depends on if the operator is attached to the right of the operand (postfx) or to the left of the operand (prefx). Within C++ postfx and prefx do not have the same precedence.