Scope operator and Iterator
Why in the declaration of an iterator with C++ is necessary the scope operator "::"?
std::vector<in开发者_运维知识库t>::iterator i;
Because iterator
is not defined in the global scope, it's a type defined in the std::vector<int>
class.
This also mean that you could have more classes named iterator
in different scopes, for example std::list<...>::iterator
, std::set<...>::iterator
, std::map<...>::iterator
and so on; all those are different classes, all with name iterator
but each defined in a different class.
iterator is a typedef in the class std::vector<>
精彩评论