好吧,所以我在我的代码中有错误,其中包括一个迭代器.
这是我的代码的错误部分:
for(list<char>::iterator it = eatUpRight.begin();it!= eatUpRight.end();it+=2)
{
board[*it][*(it+1)]=3;
_3eat2(*it,*(it+1),eatOptions,newCurrentEatingOption);
board[*it][*(it+1)]=0;
}
Run Code Online (Sandbox Code Playgroud)
不要担心电路板和_3eat2以及任何其他标识符,因为这不是问题所在.
你需要知道的是,该板是一个二维阵列.
board[*it][*(it+1)]
Run Code Online (Sandbox Code Playgroud)
(它)是2d数组的索引,但它给了我错误.并在我试图使用迭代器的其他地方给我其他错误.
那么请告诉我这段代码有什么问题吗?
it + 1仅适用于RandomAccessIterators.list不提供RandomAccessIterators,但BidirectionalIterators.请在此处查看迭代器库的概述.使用std :: advance来抽象出这些操作的区别.
| 归档时间: |
|
| 查看次数: |
130 次 |
| 最近记录: |