> also made a destructor for the class, because I dynamically 
> create some strings, so I figured they need to be freed in 
> the destructor. 

If you destroy a fltk container widget (e.g. a group or a window) then
it will destroy all its child widgets for you, so you do not have to. If
you then try and destroy them again explicitly... Bad things.

Any strings or etc you new/malloc you probably should delete/free, since
fltk will not know about them (they are not fltk objects).

However, IF the lifetime or you widgets is the lifetime of your code
running (i.e. nothing gets deleted until the program exits) then you
probably do not need to call the destructors at all (for anything) - the
OS will automatically release any allocated resources, and will do so
much more quickly and efficiently than calling the widget destructors
ever can.

The exception would be if the widget destructor performs some specific
action that you depend on, in which case you probably would want to
trigger it explicitly. This is not often necessary.

Note: It is common for people to be taught that you *must* call the
destructors for anything you *new* - but I'd suggest that the folk who
teach this approach have never written any serious code...!



SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

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

Reply via email to