This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
typedef in templated base class, won't compile
- From: John Gateley <gateley at jriver dot com>
- To: gcc-help at gcc dot gnu dot org
- Date: Thu, 25 Oct 2007 17:09:11 -0500
- Subject: typedef in templated base class, won't compile
Hi, I'm having problems using typedef within a templated base class:
#include <stdio.h>
template<class TEMPLATE_ARG>
class Base
{
public:
typedef int MyType;
};
template<class TEMPLATE_ARG>
class Child : public Base<TEMPLATE_ARG>
{
public:
MyType *MakeObject();
};
The compiler is complaining about "MyType *MakeObject();":
NestedTypedef.C:14: error: ISO C++ forbids declaration of 'MyType' with no type
NestedTypedef.C:14: error: expected ';' before '*' token
If I remove the template from the Base class, it compiles fine.
Any hints on why this won't work or what I could do to make it work?
Note that MyType is not templated, even though the base class is (and in
my short example, I don't use the TEMPLATE_ARG but in the actual code I do).
Thanks,
j
--
John Gateley <gateley@jriver.com>