Question about vector iterator in template functions

后端 未结 5 1768
慢半拍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:25

    Some compilers have problems detecting what is a member name and what is a type name, when inside templates. Try writing something like this in the first line of your template function body.

    typename vector::iterator it;

提交回复
热议问题