Re: virtual inheritance and Glib::Interface
- From: Murray Cumming <murrayc murrayc com>
- To: Jonathon Jongsma <jonathon jongsma gmail com>
- Cc: "gtkmm-list gnome org" <gtkmm-list gnome org>
- Subject: Re: virtual inheritance and Glib::Interface
- Date: Wed, 05 Apr 2006 22:12:45 +0200
On Wed, 2006-04-05 at 13:37 -0500, Jonathon Jongsma wrote:
> Just so I understand, what do you think is not true? The fact that
> multiple Interface objects might be created?
Yes. Not true, I think. Here's an attempted explanation:
Gtk::TreeStore inherits non-virtually from TreeModel, TreeSortable,
TreeDragSource, and TreeDragDest
Because each of these inherits virtually from Interface, TreeStore has
only one copy of Interface. That's kind out counterintuitive, but I
think it's how VI works. It took me (with Daniel Elstner's help) a long
to figure it out. There is great potential for this to be a huge thread
full of misunderstanding and re-explanation. What's often most
informative is to make the change and see how the compiler complains.
And feel free to test the theory with std::out in constructors.
It would only be useful to, for instance, inherit TreeModel virtually
from TreeStore and ListStore, if I was going to create classes like
this:
DerivedA : public TreeStore
DerivedB : public ListStore
DerivedDerived : public TreeStore, public ListStore
Then DerivedDerived would share one TreeModel. At the moment I think
there would be two TreeModels.
So, in general, virtual inheritance is used to make a base class
virtual, meaning shared.
So VI requires you to have some hindsight. In theory, you could make all
kinds of inheritance possible by always inheriting virtually, and I
think there is a request to add virtual inheritance somewhere else in
libsigc++ or glibmm, but it also causes all kinds of other problems and
inefficiences.
--
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]