我在声明迭代器以遍历地图并查找值时遇到问题。我收到“'fibiter'之前的预期初始化程序”错误。
map <int, int> fibHash;
int memoized_fib(int n)
{
map <int, int> iterator fibiter = fibHash.find(n); //ERROR HERE
if(fibiter != fibHash.end())
return *fibiter;
int fib_val;
if(n <= 1)
fib_val = 1;
else
fib_val = memoized_fib(n - 1) + memoized_fib(n - 2);
fibHash[n] = fib_val;
return fib_val;
}
int main()
[..]