This is the mail archive of the gcc@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]

Re: Non-default ctors, virtual base classes, & multiple inheritan ce all at once!



Greetings again,


* Jan Reimers (janr@molienergy.bc.ca) [20000906 10:43]:
> 
> 
> > -----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.


You fail to consider the following situation:

I, working for the company HoldX.com, wrote this class.

You, working for the company CvpA.com, wrote the C class and its base
classes.

In situations like this your solution is bogus at best.


The best solution I can think of is what I mentioned at the end of my
post:  To create a "wrapper" class to be the most derived class and to
specify the desired constructors for the virtual base classes (direct
and indirect).

An example of this would be:

   http://www.ktb.net/~sidster/work/mtor.cc.html


But this is still ugly imo.

Sure I can staple my Picasso to the wall for public display.  However,
one would wish for a more elegant solution.


patrick
p.s., STL is far from being elegant.
--
when i grow up i want to be a famous rock'n roll guitar player
      -- steve vai

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