auto num = 1;
auto str = "Hello";
cout << "type : " < typeid(num).name() << endl;
cout << "type : " < typeid(str).name() << endl;
for(vector<int>::iterator iter = vec.begin(); iter != vec.end(); ++iter)
{
cout<< *iter <<endl;
}
for(auto iter = vec.begin(); iter != vec.end(); ++iter)
{
cout << *iter << endl;
}
* 선호되는 방법 2가지
// vec 요소 변경 가능할 때 - 선호
for(auto &each : vec)
{
each++;
}
// vec 요소 변경 불가할 때 - 선호
for(const auto &each : vec)
{
cout<< each << endl;
}
출처 :
https://msdn.microsoft.com/ko-kr/library/jj203382.aspx
http://blog.naver.com/PostView.nhn?blogId=hextrial&logNo=220206968604&categoryNo=38&parentCategoryNo=0&viewDate=¤tPage=1&postListTopCurrentPage=1&from=section