“对于每个”微软具体? [英] Is "for each" Microsoft specific?
本文介绍了“对于每个”微软具体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Visual C ++ 2010接受:
Visual C++ 2010 accepts:
std::vector<int> v;
v.push_back(1);
v.push_back(2);
v.push_back(3);
for each (auto i in v)
std::cout << i << std::endl;
这是C ++ 11功能还是Microsoft扩展?根据维基百科,C ++ 11的for-each循环语法不同:
Is this a C++11 feature or a Microsoft extension? According to Wikipedia, the syntax of C++11's for-each loop different:
int myint[] = {1,2,3,4,5};
for (int& i: myint)
{
std::cout << i;
}
推荐答案
包括每个(auto i in v)
语法,只有为(auto i:myints)
,它只是一个扩展名。
The current standard draft does not include the for each ( auto i in v )
syntax, only the for ( auto i : myints )
, so yes, it is just an extension.
这篇关于“对于每个”微软具体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文