|
| | Subject: | typedef in templated base class, won't compile | | Group: | Gcc-help | | From: | John Gateley | | Date: | 25 Oct 2007 |
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>
|