Hi Ian, On Mon, Aug 22, 2011 at 1:51 PM, MacArthur, Ian (SELEX GALILEO, UK) < [email protected]> wrote:
> > > On Mon, Aug 22, 2011 at 1:36 PM, asif saeed > > > I read the following tutorial yesterday - it creates class > > members on stack > > > - that is, it does not make them pointers and allocate them > > using new(): > > > > > > http://www.fltk.org/doc-2.0/html/example3.html > > > > > > I have also gone through examples that create members on > > heap - that is, > > > the members are pointers - not values/objects. I have read > > in docs that > > > Fl_Group automatically deletes the children, that you add, > > upon exit. What > > > is the difference between creating members on stack and on > > heap? Don't you > > > think creating them on stack will automatically release > > them that could > > > cause Fl_Group to release non-existing memory? > > > Why do you think that would happen? > The docs say that the groups automatically add whatever children get created after them - they automatically issue a begin or something like that - apparently each widget adds itself to the group in its constructor. I read that while reading about creating members on heap using new(). I also read that the groups automatically delete the children. Now if you create children on stack then they will first be released via stack pop and then the group will delete them - and here the group will delete something that will have already been deallocated through stack unwinding. Best regards, Asif _______________________________________________ fltk mailing list [email protected] http://lists.easysw.com/mailman/listinfo/fltk

