Juan Leni
Juan Leni

Reputation: 7598

Can't compile std::list iterator with template

When I try to compile this I get this error:

error: expected `;' before 'it'

Why I can't declare this iterator? Where is the problem?

#include <list>

template <typename Z>
class LBFuncBase: public LBBaseBlock<Z>
{
    void Something() {
         std::list<LBBaseBlock< Z >* >::iterator it;
    }
};

Upvotes: 2

Views: 2230

Answers (1)

Mic
Mic

Reputation: 6981

Try:

typename std::list<LBBaseBlock< Z >* >::iterator it;

Edit:

See "Why do you sometimes need to write typename" for an explanation.

Upvotes: 13

Related Questions