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?
If by 'ID' you mean index, use
i - vec.begin()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With