According to this question, typename should be added to tell compiler that iterator is a type (Is it correct?), e.g.
template <typename T>
void print(vector<T> &v) {
for (typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
cout<<*it<<endl;
}
Two questions:
Under what circumstances should a
typenamebe added? Can someone give me another example?Can
autoin C++11 replace all thesetypename xxxcases?