G
G
Gina Lee2015-10-11 09:48:52
C++ / C#
Gina Lee, 2015-10-11 09:48:52

What does incrementing a constant iterator do?

I am writing my own random access iterator (the task is) for the list. I can not understand whether it makes sense to prescribe an increment of a constant iterator. As I understand it, a constant iterator does not change what it points to, but when an iterator (not a constant one) is increased, it simply moves further through the elements of the list. So, does a constant iterator move further down the list when incrementing? Or you just initialize it once and you can't move it anywhere?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jcmvbkbc, 2015-10-11
@Din7

const_iterator does not allow you to change the element of the collection it points to, but it moves through the collection in the same way as a non-const iterator. The analogs are const T* and just T*. Distinguish const T * from T * const.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question