Why do we need typename here?

前端 未结 4 1843
故里飘歌
故里飘歌 2020-11-27 06:02
template
class Set 
{
public:
   void insert(const T& item);
   void remove(const T& item);
private:
   std::list rep;
}

template<         


        
4条回答
  •  没有蜡笔的小新
    2020-11-27 06:47

    If you are talking of typename used with std::list::iterator:

    The typename is used to clarify that iterator is a type defined within class std::list. Without typename, std::list::iterator will be considered a static member. typename is used whenever a name that depends on a template parameter is a type.

提交回复
热议问题