In C++, we can combine two same/different operators in a single expression.

‘–>’ is not a single operator. It is a combination of two operators. i.e. Post Decrement operator & Relational operator (Greater than).

For example, consider the statement x–>1.  First, it checks if the x is greater than 1 and then decrements the x by 1.

To remove ambiguity this can be rewritten as x– > 1 which separates both operators but the result is the same.

x– decrements the value of x to 1 (i.e. equivalent to x = x-1 ).

Example:

#include <stdio.h>

int main(void) {
  int value = 10;
  while (value --> 0) { // loop runs till value becomes 0
    printf("%d ", x);
  }
  return 0;
}

To understand more about operators, please refer to the following article

Categorized in:

Tagged in: