基于范围的for循环(STL)

1.

double prices[5]={4.99,5.99,6.99,7.99,8.99};
for (double x : prices)
cout<<x<<endl;
////////////////
for (auto x : prices)
cout<<x<<endl;

不同于for_each(),基于范围的for循环可修改容器的内容,诀窍是指定一个引用参数。

原文地址:https://www.cnblogs.com/Call-C/p/5884600.html