2010-03-15 57 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