Discussion: template and typedef
Afficher un message
Vieux 21/02/2008, 16h59   #3
Kira Yamato
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: template and typedef

On 2008-02-21 05:05:38 -0500, Berardino la Torre
<berardino.latorre@hotmail.com> said:

> Hi All,
>
> is it possible to do something like this ? :
>
> template <typename Base>
> class Object : public Base::Interface {
> };


g++ seems to complain that you cannot inherit from an incomplete type Base.

This is interesting. Just when you think you've figured out how
template works, here comes another example showing you how much you
don't know.

>
> class IA{
> virtual void print()=0;
> };
>
> class A : public Object<A>{
> public:
> typedef IA A::Interface;
> void print(){
> }
> };


Seems like your goal is to have class A inherit from A::Interface. So,
why not consider the following:

class IA {};

class A : public IA
{
public:
typedef IA Interface;
};

>
>
> int main(){
>
> return 0;
> }


--

// kira

  Réponse avec citation
 
Page generated in 0,04926 seconds with 9 queries