[英]Index of vector iterator
So I have a basic vector iterator, which looks like: 所以我有一个基本的向量迭代器,看起来像:
for (std::vector<string>::iterator i = vec.begin(); i != vec.end(); ++i)
{
// Need the index here
}
I've tried using &i
but that just returns true. 我已经尝试过使用
&i
但这只会返回true。 I need to return the index. 我需要返回索引。 Would I need to create my own integer?
我需要创建自己的整数吗?
如果按“ ID”表示索引,请使用
i - vec.begin()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.