开发者

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<>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜