typename error

Sep 3, 2011 at 10:45pm
Now i have something like
1
2
3
4
5
6
template <class T> class A
{
    public:
           typename map<int,T*>::iterator Iterator;
           Iterator func(){};
};

This code gives syntax error "missing ';' before identifier 'func'"
What is wrong with it?
Sep 3, 2011 at 10:46pm
Iterator is a variable. That's like doing this:

1
2
int myvar;
myvar function();  // <- nonsense 



I think you meant to typedef it:

1
2
typedef typename map<int,T*>::iterator Iterator;
Iterator func(); // <- now this will work 
Last edited on Sep 3, 2011 at 10:46pm
Sep 3, 2011 at 10:50pm
Oh finally.. First i did something like;
typedef map<int,T*>::iterator Iterator;
but VS2010 said i should use typename... Thanks!
Topic archived. No new replies allowed.