0

Possible Duplicate:
Where and why do I have to put the “template” and “typename” keywords?
declaring a C++ set iterator

I'm trying to compile C++ some code, which works fine in Windows, in a Linux System.

I have got many errors like the following one:

code:
..
39          set<Node<T>*>::iterator child;
...

g++ gives me the error:

Node.h:39: error: expected ‘;’ before ‘child’

This is just an example. Can you give me some hint on how to solve it?

Community
  • 1
  • 1
Aslan986
  • 9,984
  • 11
  • 44
  • 75

1 Answers1

7

You have to write

typename set<Node<T>*>::iterator child;

Indeed, the compiler does not know that iterator is the name of a type defined in the templated class set. You have to tell it explicitely.

Visual Studio allows this to be implicit. gcc does not.

Didier Trosset
  • 36,376
  • 13
  • 83
  • 122