Re: virtual inheritance and Glib::Interface
- From: Murray Cumming <murrayc murrayc com>
- To: Jonathon Jongsma <jonathon jongsma gmail com>
- Cc: Chris Vine <chris cvine freeserve co uk>, gtkmm-list gnome org
- Subject: Re: virtual inheritance and Glib::Interface
- Date: Thu, 06 Apr 2006 14:20:51 +0200
On Wed, 2006-04-05 at 20:38 -0500, Jonathon Jongsma wrote:
> On 4/5/06, Chris Vine <chris cvine freeserve co uk> wrote:
> > On Wednesday 05 April 2006 22:57, Jonathon Jongsma wrote:
> > > Yes, I was not trying to suggest that ListStore inherit from TreeModel
> > > virtually, I was suggesting that since ListStore inherits from 4
> > > classes with a common ancestor (of which TreeModel is one), those 4
> > > classes should use virtual inheritance to inherit from Interface,
> > > which they don't appear to do.
> >
> > But then if they have anything other than a default constructor you can make
> > them practically unusable, because of the need to invoke the constructor from
> > the most derived class. If it doesn't matter having multiple Interface
> > objects (and I do not know if it does or it doesn't) you may be better off
> > leaving things as they are.
> >
>
> I'm not quite sure I understand your explanation.
With
- DerivedDerived : public Derived
- Derived : virtual public Base
- Base
You must do
DerivedDerived::DerivedDerived(int something)
: Derived(something),
Base(something)
Or else there must be a default Base() constructors that can be chosen
automatically.
If I do
Derived::Derived(int something)
: Base(5)
then that call to Base(5) will simply be ignored (or similar) when I
instantiate a DerivedDerived.
So, if Interface was inherited virtually then, to avoid making things
very difficult, we'd have to add an Interface() constructor. But then
the gtype-interface-adding code in the other constructor would not run.
I think people would then need to explicitly call
TreeModel::add_interface() when creating their own TreeModel, which I
don't think they need to do now.
It might be more complicated than that.
This is why we avoid virtual inheritance whenever possible. However, maybe
there's a way to make it work and save the space.
--
Murray Cumming
murrayc murrayc com
www.murrayc.com
www.openismus.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]