On 11/01/2010 09:46 PM, Rao, Anant wrote:


Thanks Krzysztof, Patrick!

You're welcome.

 

While it’s true that a char* seems to be equivalent to an iterator (in this case)

In all cases.  An iterator models pointer behavior.  Pointers were the first iterators.  A char* is a random access iterator so can be used also anywhere you would need a bidirectional, forward, output, or input iterator.

, I prefer the iterator/reverse_iterator much better. For example, if I use an iterator and it reaches end(), I can do

--it to  get to the last char.

 

In a char * model, once I reach the NULL ptr (at the end of the string), I can’t back-trackn.

That's not true.  You can do the same thing. (I assume you mean the null terminator, '\0' rather than null pointer.)  Just do --ptr to get to the last char.

Patrick