Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
Tags
- 아펠가모
- 아펠가모 선릉
- 스페인
- 마드리드
- 코틀린
- db index
- git명령어
- elk
- 코프링
- HTTP
- 400에러
- 스페인 준비물
- @Component
- kopring
- 스프링 AOP
- 본식후기
- 관심지향프로그래밍
- 코틀린 함수
- 그라나다
- Kotlin
- b-tree index
- sprintboot
- 세비야
- 아펠가모선릉
- HTTP #웹기술
- http상태코드
- 바르셀로나
- Srping AOP
- kotiln
- c# scv
Archives
- Today
- Total
끄적이는 메모장
[C++11] range for loop 본문
반응형
# range for loop
예를 들어 특정 벡터에 for loop 연산을 수행 하고 싶다.
1. 기존
vector<int> temp_vector;
for (vector<int>::iterator v = temp_vector.begin; v != temp_vector.end(); ++temp_vector)
{
....
}
2. auto를 이용할 수 있다.
1 보다 조금 더 간단 해진다.
vector<int> temp_vector;
for (auto v = temp_vector.begin; v != temp_vector.end(); ++temp_vector)
{
....
}
3. range for loop를 사용해보자
vector<int> temp_vector;
for (auto v : temp_vector)
{
....
}
단, 주의할 점은 v 의 값은 temp_vector의 값을 복사한 것으로, v의 값이 변경 된다고 해서 temp_vector의 값이 변경 되는 것은 아님!!
반응형
'C, C++, C# > C++ 공부' 카테고리의 다른 글
[C++11] std::bind, std::placeholder (0) | 2018.05.31 |
---|---|
[C++11] lambda expression (0) | 2018.05.31 |
[C++11] make_shared (0) | 2018.05.30 |
[C++11] shared_ptr / weak_ptr (0) | 2018.05.30 |
[C++11] unique_ptr / smart pointer (0) | 2018.05.30 |