Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't compile std::list iterator with template

Tags:

c++

stl

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;
    }
};
like image 827
Juan Leni Avatar asked Apr 13 '26 03:04

Juan Leni


1 Answers

Try:

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

Edit:

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

like image 111
Mic Avatar answered Apr 15 '26 16:04

Mic