繁体   English   中英

向量迭代器的索引

[英]Index of vector iterator

所以我有一个基本的向量迭代器,看起来像:

for (std::vector<string>::iterator i = vec.begin(); i != vec.end(); ++i)
{
    // Need the index here
}

我已经尝试过使用&i但这只会返回true。 我需要返回索引。 我需要创建自己的整数吗?

如果按“ ID”表示索引,请使用

i - vec.begin()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM