【问题标题】:Vector of vectors of T in template<T> classtemplate<T> 类中 T 的向量的向量
【发布时间】:2010-03-15 15:51:46
【问题描述】:

为什么这段代码不能编译(Cygwin)?

#include <vector>

template <class Ttile>
class Tilemap
{
    typedef std::vector< Ttile > TtileRow;
    typedef std::vector< TtileRow > TtileMap;
    typedef TtileMap::iterator TtileMapIterator; // error here
};

错误:输入std::vector&lt;std::vector&lt;Ttile, std::allocator&lt;_CharT&gt; &gt;, std::allocator&lt;std::vector&lt;Ttile, std::allocator&lt;_CharT&gt; &gt; &gt; &gt;' is not derived from typeTilemap'

【问题讨论】:

    标签: c++ templates vector std stdvector


    【解决方案1】:

    因为TtileMap::iterator 还不知道是一个类型。添加typename 关键字来修复它

    typedef typename TtileMap::iterator TtileMapIterator;
    

    【讨论】:

      猜你喜欢
      • 2016-06-21
      • 1970-01-01
      • 1970-01-01
      • 2013-05-06
      • 2012-12-23
      • 1970-01-01
      • 2020-02-07
      • 2015-10-03
      • 1970-01-01
      相关资源
      最近更新 更多