N
N
Nexeon2016-01-08 19:39:59
C++ / C#
Nexeon, 2016-01-08 19:39:59

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)

p.s. google doesn't mention it

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Movchan, 2016-01-08
@MrNexeon

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 question

Ask a Question

731 491 924 answers to any question