Non-default ctors, virtual base classes, & multiple inheritance all at once!

Jan Reimers janr@molienergy.bc.ca
Wed Sep 6 10:13:00 GMT 2000


> -----Original Message-----
> From: sidster [ mailto:patrick@mail.boxsoft.com ]
> Sent: Wednesday, September 06, 2000 9:33 AM
> To: Alexandre Oliva
> Cc: scherrey@switchco.com; gcc@gcc.gnu.org
> Subject: Re: Non-default ctors, virtual base classes, & multiple
> inheritance all at once!
> 
> If I understand what you are suggesting correctly then it is
> _impossible_ to get the desired behavior with the given code.
> 
> Since  template <typename X> class HoldX  has no knowledge of what
> base classes  X  might have to even provide constructors to specify
> them in its "mem-initializer-list".

template <typename X> class HoldX : public virtual X
{
  HoldX(int) : A(int),X(int) {};
};

Now the template parameter X is required to derive from A, restricting the
utility of HoldX.  But most template code places requirements on the
template parameters, STL being an example.  There is nothing earth
shattering about this.  Make virtual base classes abstract with no data, and
everything will work out.

JR



More information about the Gcc mailing list