caipengbo / Coding-Interviews

剑指offer
2 stars 0 forks source link

auto 遍历 C++11 #6

Open caipengbo opened 5 years ago

caipengbo commented 5 years ago
vector<int> vec
for(auto ele : vec){
    // 遍历序列中的元素,自动判断类型
}
for(auto& ele : vec){
    // 遍历序列中的元素,为引用,可以修改元素
}