簡體   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