为什么这段代码不能编译(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<std::vector<Ttile, std::allocator<_CharT> >, std::allocator<std::vector<Ttile, std::allocator<_CharT> > > >' is not derived from type
Tilemap'
答案 0 :(得分:4)
因为还不知道TtileMap::iterator
是一种类型。添加typename
关键字以修复它
typedef typename TtileMap::iterator TtileMapIterator;