why :: before iterator class?

I am unable to understand it clearly.

 
   std::list<int>::iterator it = mylist.begin();


specially ::iterator.
list in std namespace so use ::.
but why :: before iterator class.
The scope resolution operator :: is used for accessing things that has been declared inside namespaces and classes.
it is right.
my ? is iterator class under vector class.
actually, I have not found any hierarchy of stl.
so relation between the classes is not clear.
can you help me ?
Templated class list<T> contains type alias iterator. As type aliases are specific fpr class and not instance ("Contained in class"), you need to access them as list<T>::iterator. As list<T> itself is in std namespace, you need to access it as std::list<T>::iterator

Basically it looks like:
1
2
3
4
5
6
7
8
9
10
namespace std
{
template<typename T/*...*/>
class list
{
    using iterator = /*...*/;
    //...
};
/*...*/
}
thx,
I start to read stl. it help me to understand.
Topic archived. No new replies allowed.