> > I was trying to do my components based on the FLTK lib, but I figured out > > that the major of the components don't have virtual methods, so there is > > not way to do a secure inheritance. If, for instance, I specialize > > Fl_Widget to intercept some events by overriding int handle(int) method, > > and the user somehow calls the method by using a pointer to the basic > > class(Fl-Widget), I will have a not desired behavior. Is there a reason to > > have the classes this way(call speed?) and how the people are doing to > > specialize these classes(besides rewriting the fltk code, that I don't > > think is a good idea for maintenance)? > > Thanks, > > J.Marcelo Auler > Sorry this wasn't a good example, actually the component I'm having trouble > is Fl_Group, Fl_Widget has virtual methods for draw and handle. The only > virtual method Fl_Group has is the destructor. > I was thinking about, and the best solution I came out was to do a subclass like MyGroup, basic for all the classes that was specializing Fl_Group, but in my class I override all methods with virtual modifier and the implementation just forward to Fl_Group. And never use directly Fl_Group. I think people using Fl_Group with inheritance must take that care to not be subject to undefined behavior.( It's common to have a list of generic components like Fl_Group, and in that case your classes will behave differently). I'm using fltk 1.3, so I don't know how it is in 2.0.
_______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

