0

I am trying to create a function template containing a QList iterator :

template <typename T> void funcTemplate()
{
    QList<T>::ConstIterator it;
}

I get:

In function 'void funcTemplate()': error: expected ';' before 'it'

I tried lots of things but I can't make it compile. It is really strange because I can create a QList without problems:

template <typename T> void funcTemplate()
{
    QList<T> list;
}

Does anybody has an idea?

Thanks!

Plouff
  • 3,290
  • 2
  • 27
  • 45

1 Answers1

1

It should be

template <typename T> void funcTemplate()
{
    typename QList<T>::ConstIterator it;
}
Jarod42
  • 203,559
  • 14
  • 181
  • 302
  • Thanks! I don't really know how nested templates work. I had no idea how to find this solution. I am going to read the other thread. – Plouff Apr 28 '15 at 06:49