Question about vector iterator in template functions

后端 未结 5 1763
慢半拍i
慢半拍i 2020-12-24 07:54

I\'m trying to learn the STL library and I\'m having a weird problem. This code compiles perfectly:

void Show(vector myvec)
{
    vector

        
5条回答
  •  爱一瞬间的悲伤
    2020-12-24 08:36

    You need this:

    typename vector::iterator it;
    

    This tells the compiler that vector::iterator should be treated as a type, something it can't assume since iterator is dependent on what T is.

提交回复
热议问题