Created
April 18, 2012 15:44
-
-
Save jacking75/2414442 to your computer and use it in GitHub Desktop.
VC++의 기본적인 for each 사용법
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1. 간단 사용 법 | |
int sum=0 | |
std:;vector<int> v; | |
for each( int i in v ) | |
{ | |
sum += i; | |
} | |
std::map<string, int> con; | |
for each( std::pair<string, int> tmp in con ) | |
{ | |
........ | |
} | |
//[출처] VC++ 확장 문법 for each와 map|작성자 우영 | |
// 2. for each의 파라미터를 참조로 사용할 때 | |
std::vector<Object> objs; | |
... | |
//1. for each(const Object& o in objs) // 가능 | |
//2. for each(Object& o in objs) // 불가 | |
// 이것은 std::vector에 의한 제한임. Objs가 배열이라면 2도 가능하다고 함. | |
// 출처 : http://www.tkzdev.net/?p=183 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment