vector<string> vs = {"abc","xyz","mnq"}; vector<string>::iterator itr = vs.begin(); for(; itr != vs.end(); itr++) { cout<<*itr<<endl; } for(auto &s : vs) { cout<<s<<endl; }
int arr[10] = {1,2,3,4,5,6,7}; for(auto &i: arr) { cout<<i<<endl; } string str = "china"; for(auto& ch: str) { cout<<ch<<endl; }
map<int,string> mis={ {1,"c++"}, {2,"java"}, {3,"python"} }; map<int,string>::iterator itr = mis.begin(); for(; itr != mis.end(); ++itr) { cout<<(*itr).first<<"\t"<<itr->second<<endl; } for(auto &pair: mis) { cout<<pair.first<<"\t"<<pair.second<<endl; }