On Mon, Feb 8, 2010 at 12:49 PM, imacarthur <[email protected]> wrote:
>
> On 8 Feb 2010, at 19:09, Evan Laforge wrote:
>> But you'd still have to cast, right?  To avoid casting (in the client
>> code at least) wouldn't you need:
>>
>> virtual Fl_Group *Fl_Widget::as_group() const
>>
>
> Evan,
>
> I'm not sure I understand... Fl_Group derives from Fl_Widget, so they
> are "the same" as far as this is concerned... The method itself
> returns int (in Albrecht's implementation) but that's in effect a
> boolean... There must be something here that I am missing; where do
> we need to cast?

Well, unless I'm misunderstanding, this whole thing is about evil
upcasts, right?  You have a widget and you want to cast it to a group
and do group things to it.  So currently it's:

if (w.type() == xyz) { g = (Fl_Group) w ...

If I understand the proposal, that would make

if (w.is_group()) { g = (Fl_Group) w ...

So why not put the cast in the method:

if (Fl_Group *g = w.as_group()) { ...

_______________________________________________
fltk-dev mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-dev

Reply via email to