This operator is used to increase the value of variable by one. It works with single operator. This can only increase the value of variables. It cannot increase the value of constants and expressions. x++ and y++ are valid statements but 5++ is an invalid statements.
The functionality of the following statements is same. All these statements are equivalent. These statements increase the value of x by 1.
In the prefix form of increment operator, the increment operator is written before the variable.
Let a = ++x. In this situation the meaning of this statement is this, that it increases the value of x by 1 and after that it assigns that value to a.
In the postfix form of increment operator, the increment operator is written after the variable.
Let a = x++. In this situation the meaning of this statement is this, that it assigns the value of x to a and after that increases the value of x.
using namespace std;
c = a++;
d = ++b;
cout<<"value of c: "<<c<<endl
<<"value of a: "<<a<<endl
<<"value of b: "<<b<<endl
<<"value of d: "<<d;