我正在尝试学习c ++,所以我编写了一个使用新的c ++ 11 for循环的短程序,这使编译器给我一个我不理解的错误.这是我的c ++代码:
#include <iostream>
#include <cmath>
using namespace std;
float legge_oraria_moto_accelerato(float a[3]){
return a[2]*a[0] + 0.5*a[1]*a[0]*a[0];
}
int corri(float (f)(float array[3]), float arrays[3][3])
{ for(auto i:arrays) cout << f(i) << '\n';
return 0;
}
int main()
{
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是编译器的(g ++ -std = gnu ++ 11)错误:
mezzo.cpp: In function ‘int corri(float (*)(float*), float (*)[3])’:
mezzo.cpp:9:18: error: ‘begin’ was not declared in this scope
{ for(auto i:arrays) cout << f(i) << '\n';
^
mezzo.cpp:9:18: note: suggested …
Run Code Online (Sandbox Code Playgroud)