简体   繁体   中英

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 need to return the index. Would I need to create my own integer?

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

i - vec.begin()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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