nakka soft world !
ranged for 본문
728x90
C++11
- 기존 Style
int x[10] = {1,2,3,4,5,6,7,8,9}
for(int i =0; i<10; i++{
cout << x[i] << endl;
}
- 신규 Style
for(int n : x)
cout << n<< endl;
성능상 차이 없음,
C#, java의 foreach와 유사
int n을 auto n으로 하면 더 좋음
728x90
'프로그래밍언어 > C++' 카테고리의 다른 글
Function Overloading (0) | 2017.03.14 |
---|---|
default parameter (0) | 2017.03.14 |
using (template alias) (0) | 2017.03.09 |
nullptr (0) | 2017.03.09 |
Auto / decltype (0) | 2017.03.09 |
Comments