Error using a vector iterator in a Template class

I have a template class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
template <class T> class Foo
{
  typedef vector<T> TVector;
  ...

  void bar()
  {
    ...
    TVector tVector;
    ...
    // This line causes the error.
    for (TVector::iterator i = tVector.begin(); i < tVector.end(); i++)
    {
      ...
    }
  ...
};

And I get the following error when compiling:
1
2
AStarSearch.h:69: error: expected `;' before ā€˜i’
AStarSearch.h:69: error: ā€˜i’ was not declared in this scope 

I've tried it on Mac OS 10.5 with g++ 4.0 and Debian with g++ 4.3, and get the same error.
Do I need to do something special to be able to use a template iterator inside a template class? Or am I just overlooking something stupid?
Thanks.
Try using "typename TVector::iterator".
Try adding template <class T> right before the void in line 6.
Seymore said:
Try using "typename TVector::iterator".

Duh! It's a dependent type. Thanks for the second set of eyes.
Topic archived. No new replies allowed.