Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Intermediate
Oct 18, 2000

The Semantics of const_iterator

A recent subscriber of one of the C++ newsgroups posted the following question: Why did the C++ standardization committee created a const_iterator instead of a const iterator? Or, at least, why not require const_iterator to actually have type const iterator? The answer is simple: a const_iterator is nota const iterator. This means that you can alter the value of a const_iterator, e.g., increment it using ++. However, you cannot change the element to which a const_iterator points. In other words, if you think of an iterator as a pointer to T, a const_iterator is not a const pointer to T, but rather, it
Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap