简体   繁体   中英

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;
    }
};

Try:

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

Edit:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM