MainWindow::MainWindow(int w, int h, const string& c)
: Fl_Window(w, h, c.c_str()) // Don't call constructor over here
{
script.load_file(WIN_CONFIG_SCRIPT);
int width = script.get_global_int("width");
int height = script.get_global_int("height");
const char* caption = script.get_global_string("caption").c_str();
/** CALL CONSTRUCTOR NOW **/
//NOTE: I don't know a way to change an FLTK Fl_Window's Caption after
//initialising it.
Toolbar* toolbar = new Toolbar(0, 0, this->w(),30);
toolbar->add_button("Hello");
toolbar->add_button("World!");
end();
}
How do I initialize the base class inside the constructor? Alternatively, how do I change an FLTK Fl_Window’s caption after initialising it? Is there any other way out of this mess?
You may not.
The base part of the instance must be initialised before the derived part of the instance or any of its members.
The documentation says you can call:
What’s wrong with that?
No.
Also, you should upgrade to FLTK 2.