Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法在范围 for 循环中使用匿名数组?我正在尝试做这样的事情
for(auto i: {1,2,3,5,7,11,17}) //do something
就在这里; 它看起来像这样:
#include <initializer_list> //MUST INCLUDE THIS! for(auto i: {1,2,3,5,7,11,17}) //do something
您可能会遇到麻烦,因为没有类型......而不是自动将“i”声明为整数。
问候