const and nonconst STL Iterators

What is the difference between a ::const_iterator and an ::iterator and where would you use one over the other?

Answers


const_iterators don't allow you to change the values that they point to, regular iterators do.

As with all things in C++, always prefer const, unless there's a good reason to use regular iterators (i.e. you want to use the fact that they're not const to change the pointed-to value).


Need Your Help

Efficiency of iOS and Android in testing a word if it's correct

android ios iphone performance search

I have an app idea that relies on words... I'm still in the game design phase, and am concerned about the testing of the word for correctness. Given my research a database of English words is about...

Zeros rows returned from ADO Recordset

sql-server vba excel-vba ado recordset

I'm trying to get data from a SQL Server table into an ADO Recordset using the below code. Everything works fine with no errors, but I always get a record count of -1. I've confirmed that the datab...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.