Answer the question
In order to leave comments, you need to log in
An iterator is a pointer to the address of a container element?
The essence of the question is stated in the title. Is my judgment correct? For example:
vector<int> vec{ 2, 5, 8 };
cout << *vec.begin(); //выведет значение первого элемента (2)
Answer the question
In order to leave comments, you need to log in
An iterator is not a pointer. It is an object of the vector::iterator class that overloads its operators so that working with it looks the same as working with a pointer. For example, it overloads the denaming operators (*), the pointer member access operator (->), and the arithmetic operators (+ and -).
Yes, your code will output the value of the first element.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question