On 08/19/11 08:00, Chris wrote:
> this->win->label("TEST");
> First: is it correct to set the label inside the constructor
> or is the space for "TEST" released at the end of function?
Yes, that's fine.
All quoted strings are static, so it survives
the entire program's execution.
Static strings are not allocated or freed the way
dynamic memory is; static data is compiled into the
executable, so it's there for as long as the executable
runs.
> Second: is it the right way to release win (and it's child) with the call in
> the destructor?
Normally the way to do this would be to derive Test
from Fl_Window, so that the widget's destructor gets
called automatically. eg:
class Test : public Fl_Window {
Fl_Multiline_Output *output;
public:
Test(int X,int Y,int W,int H):Fl_Window(X,Y,W,H) {
label("TEST");
begin();
output = new Fl_Multiline_Output(0,20,250,150);
end();
show();
}
~Test() {
// fltk will handle the widget destructions.
// the only code you need here is to destroy non-fltk stuff,
// which in this case is nothing
}
}
That said, you can probably do it your way, perhaps someone
else can weigh in on that.
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk