Post

증감 연산자

1
2
3
4
5
6
7
data = 0;

++data;  // 전위(전치)
data++;  // 후위(후치)

--data;
data--;
  • 후위 연산자로 사용하는 경우, 연산자 우선순위가 가장 나중으로 밀린다.

특별한 사유가 없다면 전위로 사용하는 습관을 들이자. (실수방지)

This post is licensed under CC BY 4.0 by the author.