Bee*_*and 1 c++ compiler-errors
以下行生成编译器错误:
std::vector<int>::iterator blah = std::advance(instructions.begin(), x );
Run Code Online (Sandbox Code Playgroud)
在哪里宣布:
std::vector<int> instructions;
int x;
Run Code Online (Sandbox Code Playgroud)
我得到的错误是:
error C2440: 'initializing' : cannot convert from 'void' to 'std::_Vector_iterator<_Ty,_Alloc>'.
该陈述的哪个元素属于哪种类型void?
advance不会返回高级迭代器,它会移动作为参数传递的迭代器.所以你的代码应该是:
std::vector<int>::iterator blah = instructions.begin();
advance(blah, x);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
147 次 |
| 最近记录: |