what is the difference between const_iterator and iterator? [duplicate]
This question already has an answer here: What is the difference between const_iterator and non-const iterator in the C++ STL? 7 answers What is difference between these two regarding implementation inside STL. what is the difference regarding performance? I guess when we are traversing the vector in "read only wise", we prefer const_iterator , right? Thank you. ysdx There is no performance difference. A const_iterator is an iterator that points to const value (like a const T* pointer); dereferencing it returns a reference to a constant value ( const T& ) and prevents modification of the