nakka 2017. 3. 9. 21:39
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