Accessing vector elements inside another vector through an iterator?

An iterator is a type that can be dereferenced like a pointer, i.e. , it has an explicit operator*() and operator->() It doesn't have to be a pointer So use &*iter if you want to get the address of the vector.

An iterator is a type that can be dereferenced like a pointer, i.e. , it has an explicit operator*() and operator->(). It doesn't have to be a pointer.So use &*iter if you want to get the address of the vector.

To clarify further on MSN's answer, you can think of the iterator as a wrapper to an individual item of the container, but it also has some smarts for incrementing (++iter), decrementing (++iter) etc. Remember, the underlying data structure may not be a contiguous block of memory depending on the container type / implementation. To access the actual value, you can 1) derefence the iterator, eg Type t = *iter; 2) treat the iterator as a pointer to the container type, eg iter->someFuncOnTheContainerType().

I know it's obvious now (in hindsight), but in your for loop you could also try: std::vector & cha = * iter; Also, not what you are asking for, and just FYI, but vectors support random access iterators. Meaning you could also write: for( size_t i=0; i.

An iterator is a type that can be dereferenced like a pointer, i.e. , it has an explicit operator*() and operator->(). It doesn't have to be a pointer.

So use &*iter if you want to get the address of the vector.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions