I\'m reading C++ Primer 5th, and I encounter code that looks like this:
string s(\"some string\");
if (s.begin() != s.end())
{
auto it = s.
Shouldn't it just be a char type variable and not a pointer?
"it" is an iterator(pointer like object) and not a pointer. There are definite benefits of choosing iterators over pointers. One striking benefit is to separate algorithm from Containers. Thus have generic algorithms(constrained only by the type of iterators) and thus decouple Containers from algorithms.
Pls have a look at STL iterators - purpose.