I've been trying to find the key of a vector, but when I try to access the vector with an iterator and try to return a value it complains about "first" or "second" not being a member of the iterator.
I've been googling to find a way to return key values but I only found it for maps, not vectors.
When using std::map you can use first and second because the key-value pairs is stored in std::pair that has public data members called first and second. std::vector stores all elements in a contiguous array and doesn't have keys. Well, you could argue that the index is the key but it's not stored anywhere. You should use *it to get the string from the iterator. If you want to calculate the index of the string in the vector you can do that by calculating the distance between it and the first iterator, it - treatmentNames.begin() or std::distance(treatmentNames.begin(), it).