2010-03-15 158 views
0

为什么这段代码不能编译(Cygwin)?向量模板中的T向量向量<T>类

#include <vector> 

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

error: type std::vector<std::vector<Ttile, std::allocator<_CharT> >, std::allocator<std::vector<Ttile, std::allocator<_CharT> > > >' is not derived from type Tilemap'

回答

4

由于TtileMap::iterator不知道是一种类型的爱好。添加typename关键字来修复它

typedef typename TtileMap::iterator TtileMapIterator; 
+0

typename,right!感谢你的回答。 – 2010-03-15 16:00:03