开发者

Vector of vectors of T in template<T> class

开发者 https://www.devze.com 2022-12-23 03:27 出处:网络
Why this code does not compile (Cygwin)? #include <开发者_如何学JAVAvector> template <class Ttile>

Why this code does not compile (Cygwin)?

#include <开发者_如何学JAVAvector>

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 typeTilemap'


Because the TtileMap::iterator is not known to be a type yet. Add the typename keyword to fix it

typedef typename TtileMap::iterator TtileMapIterator;
0

精彩评论

暂无评论...
验证码 换一张
取 消