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 use the second form frequently because I'm often working with control interactions. E.g. if I have a button in my GUI which impacts
other controls (such as a 'Reset' button). As alluded to in erco's first reply: "unless the pointer is saved somewhere else." - pointers to
the impacted controls need to be kept around so (in this case) the button callback can "talk" to them. So a simple, contrived example:
// Kept pointers
Fl_Int_Input *inpDollarAmount;
Fl_Int_Input *inpOther;
...
// GUI construction
inpDollarAmount = new Fl_Int_Input(25, 20, 75, 25, "Amount:");
Fl_Button *btnReset = new Fl_Button(25, 50, 75, 25, "Reset");
btnReset->callback(onReset);
...
// Reset button callback: clears all input controls
void onReset(Fl_Widget *w, void *d)
{
inpDollarAmount->value(0); // callback can't access the control without the pointer
inpOther->value(0);
}