> {
> int i;
> delete &i; //this works but blows up big-time, of course. But compiler
> doesn't check it at compile time.
> }
>
It's not watertight, but my proof-by-example is that I've never seen this
happen with FLTK ;-)
> > You also don't have your deallocation ordering strictly correct. The stack
> > unwind will always be the last-constructed order - so if you declare a
> > Fl_Group above a Fl_Widget, the Fl_Widget will be destructed *before* the
> > Fl_Group.
> >
>
> Ya, I know - I call it DMB (DUMB) destruction - (D)erived classes, (M)embers
> and (B)ase. I probably mis-typed something in a hurry.
Even still, not quite. Per-object this is right, but all derived classes aren't
destroyed together, and then all members, etc. Though I assume you know this
already.
> Hopefully this answers your question. The group will never delete anything
> > that has been deallocated via the stack, and vice versa.
>
>
> That's exactly what I wanted to know. But the question remans: when should I
> create member widgets as pointers and when should I create them as direct
> object members (non pointers, that is)?
Well, this is an entirely different question; when to use a pointer vs when to
use an object. This depends on a heap of things; cache locality being one (if
you're not updating objects constantly, you'll get more benefit from the cpu
cache in using objects). Pointers can also use magic to be casted up and down
the derived tree; objects can't.
There are a myriad of reasons to use one over the other; I'm sure others in
this list have much to offer here.
Ben
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk