Re: template and typedef
Berardino la Torre wrote:
> Hi All,
>
> is it possible to do something like this ? :
[Summarized for brevity:]
template <typename Base>
struct Object: Base::Interface { };
struct IA { virtual void print() =0; };
struct A: Object<A> {
typedef IA A::Interface;
void print() { }
};
You're trying to derive a class (indirectly) from a type defined within
that class. I don't know of any direct way to do that. You can instead
move the type definition outside the class itself, e.g. into a traits class:
template<typename T>
struct Interface;
template <typename Base>
struct Object: Interface<Base>::Type { };
struct IA { virtual void print() =0; };
struct A;
template<>
struct Interface<A> {
typedef IA Type;
};
struct A: Object<A> {
void print() { }
};
|