problem with a structure nested within a template

Paul Ianna paulianna2002@gmail.com
Tue Nov 21 18:05:00 GMT 2006


Hi All,

I'm perplexed and hoping to obtain some guru insight from the community.

The code below is a snippet from some existing code that compiles with
many other compilers, but not gcc (I tried both 3.4.4 and 4.1.1
versions).

The problem line is:  C1<U>::Node*    pNode;

and the error is:  error: expected `;' before '*' token

If I use a concrete type (e.g., C1<int>), all is well.

Thanks in advance,
Paul


///////////////////////////////////////
template<typename T>
class C1
{
public:

   struct Node
   {
      T*     prev;
      T*     next;
   };

   Node   myNode;
};



///////////////////////////////////////
template<typename U>
class C2
{
public:

   U                       someObj;
   C1<U>::Node*    pNode;
};


///////////////////////////////////////
int main()
{
   C1<int> c1;

   C2<int> c2;

   return 0;
}



More information about the Gcc-help mailing list