小编Jea*_*ean的帖子

在模板类中定义迭代器时出现STL编译错误

下面的代码给出了错误:

error: type ‘std::list<T,std::allocator<_Tp1> >’ is not derived from type ‘Foo<T>’
error: expected ‘;’ before ‘iter’

#include <list>

template <class T> class Foo 
{
  public:
      std::list<T>::iterator iter;

  private:
      std::list<T> elements;
};
Run Code Online (Sandbox Code Playgroud)

为什么以及这应该是正确的?

c++ stl

5
推荐指数
1
解决办法
869
查看次数

标签 统计

c++ ×1

stl ×1