기본 콘텐츠로 건너뛰기

3월, 2013의 게시물 표시

잘 알려지지 않은 VC 명령어 (for each 문)

vs2005 이상에서 지원하는 "for each"문.. 난 왜 모르고 있었을까요..--;; 한눈에 훨씬 잘 들어 오는군요. - 정의 http://msdn.microsoft.com/en-us/library/ms177202(v=vs.80).aspx - 사용예 http://msdn.microsoft.com/en-US/library/ms177203(v=vs.80).aspx // for_each_stl.cpp // compile with: /EHsc #include <map> #include <iostream> using namespace std; int main() { int retval = 0; map<const char*, int> months; months["january"] = 31; months["february"] = 28; months["march"] = 31; months["april"] = 30; months["may"] = 31; months["june"] = 30; months["july"] = 31; months["august"] = 31; months["september"] = 30; months["october"] = 31; months["november"] = 30; months["december"] = 31; map<const char*, int> months_30; for each( pair<const char*, int> c in months ) if ( c.second == 30 )