This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]