#include <iostream>
using namespace std;
int main()
{
constexpr size_t b = 10;
int arr[b];
for (int i = 0; i<b; i++)
{
arr[i] = i;
}
for (int x : b)
{
cout<<x;
}
}
代码显示在上面。 为什么我不能使用范围for循环打印数组的内容?当我尝试时,它给了我一个错误,说 错误:没有匹配函数调用'开始(const无符号int &)'|错误:无法调用'begin(const unsigned int&)'的匹配函数|
你正在寻找替换第一回路的算法'的std :: iota'。 – chris