-
std::list and iterators
Assuming you have an std::list (or other container) iterator and want it to point at 'nothing' you assign it List.end(). Ok, now if you don't have a specific list available (these cases occur) how can you nullify it? Would NULL be acceptable? (have my doubts about this...).
-
>how can you nullify it?
You don't. There's really no reason for an iterator that isn't paired with a container, so such an assignment would be nonsensical.
>Would NULL be acceptable?
No.
-
Iterators are objects that can iterate over elements of a sequence so they're not pointers. NULL can be assigned to pointer. Iterator is an object and can act like a "smart pointer", but it's still and object!!!
Iterators are objects that can iterate over elements of a sequence so they're not pointers. NULL can be assigned only to a pointer. Iterator is an object and can act like a "smart pointer", but it's still and object!!!Remember: each container type supplies its own kind of iterator. In fact, each container class defines its iterator type as a nested class. As a result, iterators share the same interface but have different types.
NULL is in C++ defined as 0. Do you understand now why NULL is not an option here?