Re: Gtk::Widget as virtual base
- From: jyotirmoy bhattacharya <jmoy matecon gmail com>
- To: gtkmm-list gnome org
- Subject: Re: Gtk::Widget as virtual base
- Date: Tue, 31 May 2005 17:17:17 +0530
Thanks for your interest.
> Maybe you can resolve most of this ambiguitys with using virtual
> inheritance. The problem is, that
>[ keyword diamond inheritance ]
> for doing this, both classes you inherit from should use virtual
> inhertitance from Gtk::Widget. I guess this is not the case for
> Gtk::HBox, so using virtual inheritance for vwwidget only doesn't >help.
Why dosen't gtkmm make Gtk::Widget a virtual base of widgets
like Gtk::Hbox? I can't think of any programs that
might by broken by such a change but being a gtkmm newbie
I really don't know.
> Maybe there is an easier way to do what you want to do ...
The workaround that I am using at present is
class vwidget
{
public:
virtual void magic()=0;
virtual Gtk::Widget *get_widget()=0;
};
class mywidget: public vwidget
{
public:
void magic() {x=1;}
Gtk::Widget *get_widget() {return &box;}
private:
int x;
Gtk::Hbox box;
};
But besides being inelegant, this is a maintenance problem
since the actual class corresponding to mywidget is displayed
by using a large hierarchy of widgets and everytime I change
the root of that hierarchy I have to remember to update
get_widget(). If I forget to do so the mistake is not caught during
compilation and leads to obscure runtime errors.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]