By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

Is iterator definition with template not a type in ISO C++?

P: n/a

Hi,

I tried to declare an iterator inside a template class, but the compiler
regards list<State>::iterator as an expression, instead of an iterator.

#include <list>

template <class State>
class Problem
{
..
..
..
list<State>::iterator itr;
..
..
..
}

What's wrong here, what should I do to fix this problem?

Thanks a lot!
Xin Wang

Jul 23 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a

"Xin Wang" <wa****@yahoo.com> wrote in message
news:Pi*******************************@flop.ENGR.O RST.EDU...

Hi,

I tried to declare an iterator inside a template class, but the compiler
regards list<State>::iterator as an expression, instead of an iterator.

#include <list>

template <class State>
class Problem
{
.
.
.
list<State>::iterator itr;


This changes to:
typename std::list<State>::iterator itr;
Regards,
Sumit.
--
Sumit Rajan <su*********@gmail.com>
Jul 23 '05 #2

P: n/a

"Sumit Rajan" <su*********@gmail.com> wrote in message
news:3b*************@individual.net...
This changes to:
typename std::list<State>::iterator itr;


I should have explained why the word "typename" comes into the picture. It
is used to clarify that "iterator" is a type (and not a static member of
list).

Regards,
Sumit.
--
Sumit Rajan <su*********@gmail.com>
Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.