Hi, new to FLTK (and FLUID) and really like it. Have figured out a few things but not sure why there is syntax variations between what FLUID produces and example code I can find. I do not know much about C++ or ObjectOrientation (I am an assembler programmer) but think it might be more about that then anything else. I've posted the following example:-
The first form declares an instance of an Fl_Button class called 'fltkButton'.Both button instances are 'initialized' with the x,y,w,h values and the
This instance and name has a lifetime up to the closing brace for the block
of code it's declared in (which is main()). When the closing brace is reached,
the instance is automatically destroyed. This is similar to declaring a
variable in C; if you declare 'int x = 0;' it will be created and visible up
until the closing brace.
The second form declares a pointer called fluidButton, and initializes it
to point to an instance of Fl_Button created with 'new'. The instance's
lifetime makes it available until the pointer is destroyed with 'delete',
and the pointer's lifetime is only visible until the closing brace, unless
the pointer is saved somewhere else.
On 9/15/22 22:42, roger tunnicliffe wrote:
Subject: ..My original post seemed to disappear..
On 9/16/22 02:45, imm wrote:
On 9/15/22 22:42, roger tunnicliffe wrote: Subject: ..My original post seemed to disappear..It didn't disappear, it just takes time to be moderated and approved.Yeah, I had a dentist appointment
Heh, you usually always beat me to moderation these days..
Thx for the reply (sorry can't see your name).
I am wondering then what would be the use cases for each particular syntactical version. ie.When and why would i use this code....Fl_Button fltkButton(25, 20, 70, 50, "button1");noting it requires fltkButton.labelsize(12);as opposed to this code....Fl_Button *fluidButton = new Fl_Button(25, 80, 70, 50, "button2");noting it requires fltkButton->labelsize(12);
Thx for the reply (sorry can't see your name).
I am wondering then what would be the use cases for each particular syntactical version. ie.
When and why would i use this code....Fl_Button fltkButton(25, 20, 70, 50, "button1");noting it requires fltkButton.labelsize(12);as opposed to this code....Fl_Button *fluidButton = new Fl_Button(25, 80, 70, 50, "button2");noting it requires fltkButton->labelsize(12);
I am wondering then what would be the use cases for each particular syntactical version. ie.
When and why would i use this code....Fl_Button fltkButton(25, 20, 70, 50, "button1");noting it requires fltkButton.labelsize(12);as opposed to this code....Fl_Button *fluidButton = new Fl_Button(25, 80, 70, 50, "button2");noting it requires fltkButton->labelsize(12);
On 9/16/22 14:48, roger tunnicliffe wrote:
Thx for the reply (sorry can't see your name).
I am wondering then what would be the use cases for each particular syntactical version. ie.
When and why would i use this code....Fl_Button fltkButton(25, 20, 70, 50, "button1");noting it requires fltkButton.labelsize(12);as opposed to this code....Fl_Button *fluidButton = new Fl_Button(25, 80, 70, 50, "button2");noting it requires fltkButton->labelsize(12);
Probably no good reason, other than it's shorter.
If you're new to C++, I'd suggest always using 'new' to create
FLTK widgets so you don't have to worry about widgets going
out of scope prematurely.