views:

46

answers:

1

Why this code does not compile (Cygwin)?

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

+3  A: 

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

typedef typename TtileMap::iterator TtileMapIterator;
KennyTM
typename, right! Thanks for the answer.
topright