On Wed, 2012-11-07 at 13:34 -0600, [email protected] wrote: > Hello All, > > In the Gtkmm tutorial (http://developer.gnome.org/gtkmm-tutorial/2.24) > many of the examples are implemented by having the user defined > example class derive from a Gtkmm class. Most likely many (if not > all), of these examples could of been implemented by using some form > of composition instead of derivation. As you all know, in C++, > composition is generally preferred over derivation. Which leads me to > ask, in the context of Gtkmm, is there a rationale for preferring > derivation over composition (or vice-versa). What are the pros and > cons of each approach in implementing your UI using Gtkmm?
From memory, I think the examples use a combination of inheritance and composition. For example, a lot of the examples have their own window class that derives from Gtk::Window. That's inheritance. However, whenever a widget class in the examples includes a declaration of a widget that it uses in some way (maybe to form part of its own presentation), composition is being used in that case. Both methods have their usefulness depending on what you want to accomplish and gtkmm supports both. > TIA, > Kenton > > _______________________________________________ > gtkmm-list mailing list > [email protected] > https://mail.gnome.org/mailman/listinfo/gtkmm-list -- José _______________________________________________ gtkmm-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gtkmm-list
